mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
component/bt : run astyle handle the code files
This commit is contained in:
485
components/bt/bluedroid/stack/smp/smp_utils.c
Executable file → Normal file
485
components/bt/bluedroid/stack/smp/smp_utils.c
Executable file → Normal file
@@ -54,8 +54,7 @@
|
||||
#define SMP_PAIR_KEYPR_NOTIF_SIZE (1 /* opcode */ + 1 /*Notif Type*/)
|
||||
|
||||
/* SMP command sizes per spec */
|
||||
static const UINT8 smp_cmd_size_per_spec[] =
|
||||
{
|
||||
static const UINT8 smp_cmd_size_per_spec[] = {
|
||||
0,
|
||||
SMP_PAIRING_REQ_SIZE, /* 0x01: pairing request */
|
||||
SMP_PAIRING_REQ_SIZE, /* 0x02: pairing response */
|
||||
@@ -82,8 +81,7 @@ typedef BOOLEAN (*tSMP_CMD_LEN_VALID)(tSMP_CB *p_cb);
|
||||
|
||||
static BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb);
|
||||
|
||||
static const tSMP_CMD_LEN_VALID smp_cmd_len_is_valid[] =
|
||||
{
|
||||
static const tSMP_CMD_LEN_VALID smp_cmd_len_is_valid[] = {
|
||||
smp_parameter_unconditionally_invalid,
|
||||
smp_command_has_valid_fixed_length, /* 0x01: pairing request */
|
||||
smp_command_has_valid_fixed_length, /* 0x02: pairing response */
|
||||
@@ -108,8 +106,7 @@ typedef BOOLEAN (*tSMP_CMD_PARAM_RANGES_VALID)(tSMP_CB *p_cb);
|
||||
static BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb);
|
||||
static BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb);
|
||||
|
||||
static const tSMP_CMD_PARAM_RANGES_VALID smp_cmd_param_ranges_are_valid[] =
|
||||
{
|
||||
static const tSMP_CMD_PARAM_RANGES_VALID smp_cmd_param_ranges_are_valid[] = {
|
||||
smp_parameter_unconditionally_invalid,
|
||||
smp_pairing_request_response_parameters_are_valid, /* 0x01: pairing request */
|
||||
smp_pairing_request_response_parameters_are_valid, /* 0x02: pairing response */
|
||||
@@ -129,7 +126,7 @@ static const tSMP_CMD_PARAM_RANGES_VALID smp_cmd_param_ranges_are_valid[] =
|
||||
};
|
||||
|
||||
/* type for action functions */
|
||||
typedef BT_HDR * (*tSMP_CMD_ACT)(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
typedef BT_HDR *(*tSMP_CMD_ACT)(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
|
||||
static BT_HDR *smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
static BT_HDR *smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
@@ -146,8 +143,7 @@ static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
static BT_HDR *smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb);
|
||||
|
||||
static const tSMP_CMD_ACT smp_cmd_build_act[] =
|
||||
{
|
||||
static const tSMP_CMD_ACT smp_cmd_build_act[] = {
|
||||
NULL,
|
||||
smp_build_pairing_cmd, /* 0x01: pairing request */
|
||||
smp_build_pairing_cmd, /* 0x02: pairing response */
|
||||
@@ -166,106 +162,148 @@ static const tSMP_CMD_ACT smp_cmd_build_act[] =
|
||||
smp_build_pairing_commitment_cmd /* 0x0F: pairing commitment */
|
||||
};
|
||||
|
||||
static const UINT8 smp_association_table[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] =
|
||||
{
|
||||
static const UINT8 smp_association_table[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] = {
|
||||
/* display only */ /* Display Yes/No */ /* keyboard only */
|
||||
/* No Input/Output */ /* keyboard display */
|
||||
/* No Input/Output */ /* keyboard display */
|
||||
|
||||
/* initiator */
|
||||
/* model = tbl[peer_io_caps][loc_io_caps] */
|
||||
/* Display Only */
|
||||
{{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY},
|
||||
/* initiator */
|
||||
/* model = tbl[peer_io_caps][loc_io_caps] */
|
||||
/* Display Only */
|
||||
{ {
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY
|
||||
},
|
||||
|
||||
/* Display Yes/No */
|
||||
{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY},
|
||||
/* Display Yes/No */
|
||||
{
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY
|
||||
},
|
||||
|
||||
/* Keyboard only */
|
||||
{SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF},
|
||||
/* Keyboard only */
|
||||
{
|
||||
SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF
|
||||
},
|
||||
|
||||
/* No Input No Output */
|
||||
{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY},
|
||||
/* No Input No Output */
|
||||
{
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY
|
||||
},
|
||||
|
||||
/* keyboard display */
|
||||
{SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF}},
|
||||
/* keyboard display */
|
||||
{
|
||||
SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF
|
||||
}
|
||||
},
|
||||
|
||||
/* responder */
|
||||
/* model = tbl[loc_io_caps][peer_io_caps] */
|
||||
/* Display Only */
|
||||
{{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF},
|
||||
/* responder */
|
||||
/* model = tbl[loc_io_caps][peer_io_caps] */
|
||||
/* Display Only */
|
||||
{ {
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF
|
||||
},
|
||||
|
||||
/* Display Yes/No */
|
||||
{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF},
|
||||
/* Display Yes/No */
|
||||
{
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF
|
||||
},
|
||||
|
||||
/* keyboard only */
|
||||
{SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY},
|
||||
/* keyboard only */
|
||||
{
|
||||
SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY
|
||||
},
|
||||
|
||||
/* No Input No Output */
|
||||
{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY},
|
||||
/* No Input No Output */
|
||||
{
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY
|
||||
},
|
||||
|
||||
/* keyboard display */
|
||||
{SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY}}
|
||||
/* keyboard display */
|
||||
{
|
||||
SMP_MODEL_PASSKEY, SMP_MODEL_PASSKEY, SMP_MODEL_KEY_NOTIF,
|
||||
SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const UINT8 smp_association_table_sc[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] =
|
||||
{
|
||||
/* display only */ /* Display Yes/No */ /* keyboard only */
|
||||
/* No InputOutput */ /* keyboard display */
|
||||
static const UINT8 smp_association_table_sc[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] = {
|
||||
/* display only */ /* Display Yes/No */ /* keyboard only */
|
||||
/* No InputOutput */ /* keyboard display */
|
||||
|
||||
/* initiator */
|
||||
/* model = tbl[peer_io_caps][loc_io_caps] */
|
||||
/* initiator */
|
||||
/* model = tbl[peer_io_caps][loc_io_caps] */
|
||||
|
||||
/* Display Only */
|
||||
{{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT},
|
||||
/* Display Only */
|
||||
{ {
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT
|
||||
},
|
||||
|
||||
/* Display Yes/No */
|
||||
{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP},
|
||||
/* Display Yes/No */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP
|
||||
},
|
||||
|
||||
/* keyboard only */
|
||||
{SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP},
|
||||
/* keyboard only */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP
|
||||
},
|
||||
|
||||
/* No Input No Output */
|
||||
{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS},
|
||||
/* No Input No Output */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS
|
||||
},
|
||||
|
||||
/* keyboard display */
|
||||
{SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP}},
|
||||
/* keyboard display */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_PASSKEY_DISP, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP
|
||||
}
|
||||
},
|
||||
|
||||
/* responder */
|
||||
/* model = tbl[loc_io_caps][peer_io_caps] */
|
||||
/* responder */
|
||||
/* model = tbl[loc_io_caps][peer_io_caps] */
|
||||
|
||||
/* Display Only */
|
||||
{{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP},
|
||||
/* Display Only */
|
||||
{ {
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_DISP
|
||||
},
|
||||
|
||||
/* Display Yes/No */
|
||||
{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP},
|
||||
/* Display Yes/No */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP
|
||||
},
|
||||
|
||||
/* keyboard only */
|
||||
{SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT},
|
||||
/* keyboard only */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_PASSKEY_ENT,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_PASSKEY_ENT
|
||||
},
|
||||
|
||||
/* No Input No Output */
|
||||
{SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS},
|
||||
/* No Input No Output */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_JUSTWORKS
|
||||
},
|
||||
|
||||
/* keyboard display */
|
||||
{SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP}}
|
||||
/* keyboard display */
|
||||
{
|
||||
SMP_MODEL_SEC_CONN_PASSKEY_ENT, SMP_MODEL_SEC_CONN_NUM_COMP, SMP_MODEL_SEC_CONN_PASSKEY_DISP,
|
||||
SMP_MODEL_SEC_CONN_JUSTWORKS, SMP_MODEL_SEC_CONN_NUM_COMP
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb);
|
||||
@@ -283,23 +321,21 @@ BOOLEAN smp_send_msg_to_L2CAP(BD_ADDR rem_bda, BT_HDR *p_toL2CAP)
|
||||
UINT16 l2cap_ret;
|
||||
UINT16 fixed_cid = L2CAP_SMP_CID;
|
||||
|
||||
if (smp_cb.smp_over_br)
|
||||
{
|
||||
if (smp_cb.smp_over_br) {
|
||||
fixed_cid = L2CAP_SMP_BR_CID;
|
||||
}
|
||||
|
||||
SMP_TRACE_EVENT("%s", __FUNCTION__);
|
||||
smp_cb.total_tx_unacked += 1;
|
||||
|
||||
if ((l2cap_ret = L2CA_SendFixedChnlData (fixed_cid, rem_bda, p_toL2CAP)) == L2CAP_DW_FAILED)
|
||||
{
|
||||
if ((l2cap_ret = L2CA_SendFixedChnlData (fixed_cid, rem_bda, p_toL2CAP)) == L2CAP_DW_FAILED) {
|
||||
smp_cb.total_tx_unacked -= 1;
|
||||
SMP_TRACE_ERROR("SMP failed to pass msg:0x%0x to L2CAP",
|
||||
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
|
||||
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -316,13 +352,11 @@ BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
UINT8 failure = SMP_PAIR_INTERNAL_ERR;
|
||||
SMP_TRACE_EVENT("smp_send_cmd on l2cap cmd_code=0x%x\n", cmd_code);
|
||||
if ( cmd_code <= (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */) &&
|
||||
smp_cmd_build_act[cmd_code] != NULL)
|
||||
{
|
||||
smp_cmd_build_act[cmd_code] != NULL) {
|
||||
p_buf = (*smp_cmd_build_act[cmd_code])(cmd_code, p_cb);
|
||||
|
||||
if (p_buf != NULL &&
|
||||
smp_send_msg_to_L2CAP(p_cb->pairing_bda, p_buf))
|
||||
{
|
||||
smp_send_msg_to_L2CAP(p_cb->pairing_bda, p_buf)) {
|
||||
sent = TRUE;
|
||||
|
||||
btu_stop_timer (&p_cb->rsp_timer_ent);
|
||||
@@ -331,14 +365,10 @@ BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
}
|
||||
}
|
||||
|
||||
if (!sent)
|
||||
{
|
||||
if (p_cb->smp_over_br)
|
||||
{
|
||||
if (!sent) {
|
||||
if (p_cb->smp_over_br) {
|
||||
smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &failure);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
|
||||
}
|
||||
}
|
||||
@@ -362,12 +392,9 @@ void smp_rsp_timeout(TIMER_LIST_ENT *p_tle)
|
||||
|
||||
SMP_TRACE_EVENT("%s state:%d br_state:%d", __FUNCTION__, p_cb->state, p_cb->br_state);
|
||||
|
||||
if (p_cb->smp_over_br)
|
||||
{
|
||||
if (p_cb->smp_over_br) {
|
||||
smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &failure);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure);
|
||||
}
|
||||
}
|
||||
@@ -379,14 +406,13 @@ void smp_rsp_timeout(TIMER_LIST_ENT *p_tle)
|
||||
** Description Build pairing request command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
BT_HDR *smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
|
||||
SMP_TRACE_EVENT("smp_build_pairing_cmd");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, cmd_code);
|
||||
@@ -412,15 +438,14 @@ BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build confirm request command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("smp_build_confirm_cmd\n");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_CONFIRM);
|
||||
@@ -439,7 +464,7 @@ static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build Random command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
@@ -447,8 +472,7 @@ static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET))
|
||||
!= NULL)
|
||||
{
|
||||
!= NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_RAND);
|
||||
@@ -467,15 +491,14 @@ static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build security information command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("smp_build_encrypt_info_cmd\n");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_ENCRYPT_INFO);
|
||||
@@ -495,7 +518,7 @@ static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build security information command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
@@ -503,8 +526,7 @@ static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_MASTER_ID);
|
||||
@@ -525,7 +547,7 @@ static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build identity information command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
@@ -534,8 +556,7 @@ static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
UNUSED(p_cb);
|
||||
|
||||
SMP_TRACE_EVENT("smp_build_identity_info_cmd\n");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
BTM_GetDeviceIDRoot(irk);
|
||||
@@ -557,7 +578,7 @@ static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build identity address information command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL;
|
||||
UINT8 *p;
|
||||
@@ -565,8 +586,7 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
UNUSED(cmd_code);
|
||||
UNUSED(p_cb);
|
||||
SMP_TRACE_EVENT("smp_build_id_addr_cmd\n");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_ID_ADDR);
|
||||
@@ -587,15 +607,14 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build signing information command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("smp_build_signing_info_cmd\n");
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_SIGN_INFO);
|
||||
@@ -615,15 +634,14 @@ static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build Pairing Fail command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_PAIRING_FAILED);
|
||||
@@ -650,8 +668,7 @@ static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_SEC_REQ);
|
||||
@@ -660,7 +677,7 @@ static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_buf->len = SMP_SECURITY_REQUEST_SIZE;
|
||||
|
||||
SMP_TRACE_EVENT("opcode=%d auth_req=0x%x",SMP_OPCODE_SEC_REQ, p_cb->loc_auth_req );
|
||||
SMP_TRACE_EVENT("opcode=%d auth_req=0x%x", SMP_OPCODE_SEC_REQ, p_cb->loc_auth_req );
|
||||
}
|
||||
|
||||
return p_buf;
|
||||
@@ -678,7 +695,7 @@ static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
UINT8 publ_key[2*BT_OCTET32_LEN];
|
||||
UINT8 publ_key[2 * BT_OCTET32_LEN];
|
||||
UINT8 *p_publ_key = publ_key;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
@@ -688,12 +705,11 @@ static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
|
||||
SMP_PAIR_PUBL_KEY_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
SMP_PAIR_PUBL_KEY_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_PAIR_PUBLIC_KEY);
|
||||
ARRAY_TO_STREAM (p, p_publ_key, 2*BT_OCTET32_LEN);
|
||||
ARRAY_TO_STREAM (p, p_publ_key, 2 * BT_OCTET32_LEN);
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_buf->len = SMP_PAIR_PUBL_KEY_SIZE;
|
||||
@@ -717,8 +733,7 @@ static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
|
||||
!= NULL)
|
||||
{
|
||||
!= NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_CONFIRM);
|
||||
@@ -746,8 +761,7 @@ static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
|
||||
SMP_PAIR_DHKEY_CHECK_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
SMP_PAIR_DHKEY_CHECK_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_PAIR_DHKEY_CHECK);
|
||||
@@ -767,7 +781,7 @@ static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
** Description Build keypress notification command.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
static BT_HDR *smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
{
|
||||
BT_HDR *p_buf = NULL ;
|
||||
UINT8 *p;
|
||||
@@ -775,8 +789,7 @@ static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR)\
|
||||
+ SMP_PAIR_KEYPR_NOTIF_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
+ SMP_PAIR_KEYPR_NOTIF_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_PAIR_KEYPR_NOTIF);
|
||||
@@ -824,13 +837,13 @@ void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data)
|
||||
void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 *p_data)
|
||||
{
|
||||
SMP_TRACE_EVENT("smp_mask_enc_key\n");
|
||||
if (loc_enc_size < BT_OCTET16_LEN)
|
||||
{
|
||||
for (; loc_enc_size < BT_OCTET16_LEN; loc_enc_size ++)
|
||||
if (loc_enc_size < BT_OCTET16_LEN) {
|
||||
for (; loc_enc_size < BT_OCTET16_LEN; loc_enc_size ++) {
|
||||
* (p_data + loc_enc_size) = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -850,8 +863,7 @@ void smp_xor_128(BT_OCTET16 a, BT_OCTET16 b)
|
||||
UINT8 i, *aa = a, *bb = b;
|
||||
|
||||
SMP_TRACE_EVENT("smp_xor_128\n");
|
||||
for (i = 0; i < BT_OCTET16_LEN; i++)
|
||||
{
|
||||
for (i = 0; i < BT_OCTET16_LEN; i++) {
|
||||
aa[i] = aa[i] ^ bb[i];
|
||||
}
|
||||
}
|
||||
@@ -890,10 +902,11 @@ void smp_remove_fixed_channel(tSMP_CB *p_cb)
|
||||
{
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
|
||||
if (p_cb->smp_over_br)
|
||||
if (p_cb->smp_over_br) {
|
||||
L2CA_RemoveFixedChnl (L2CAP_SMP_BR_CID, p_cb->pairing_bda);
|
||||
else
|
||||
} else {
|
||||
L2CA_RemoveFixedChnl (L2CAP_SMP_CID, p_cb->pairing_bda);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -944,25 +957,28 @@ void smp_proc_pairing_cmpl(tSMP_CB *p_cb)
|
||||
evt_data.cmplt.reason = p_cb->status;
|
||||
evt_data.cmplt.smp_over_br = p_cb->smp_over_br;
|
||||
|
||||
if (p_cb->status == SMP_SUCCESS)
|
||||
if (p_cb->status == SMP_SUCCESS) {
|
||||
evt_data.cmplt.sec_level = p_cb->sec_level;
|
||||
}
|
||||
|
||||
evt_data.cmplt.is_pair_cancel = FALSE;
|
||||
|
||||
if (p_cb->is_pair_cancel)
|
||||
if (p_cb->is_pair_cancel) {
|
||||
evt_data.cmplt.is_pair_cancel = TRUE;
|
||||
}
|
||||
|
||||
|
||||
SMP_TRACE_DEBUG ("send SMP_COMPLT_EVT reason=0x%0x sec_level=0x%0x\n",
|
||||
evt_data.cmplt.reason,
|
||||
evt_data.cmplt.sec_level );
|
||||
evt_data.cmplt.reason,
|
||||
evt_data.cmplt.sec_level );
|
||||
|
||||
memcpy (pairing_bda, p_cb->pairing_bda, BD_ADDR_LEN);
|
||||
|
||||
smp_reset_control_value(p_cb);
|
||||
|
||||
if (p_callback)
|
||||
if (p_callback) {
|
||||
(*p_callback) (SMP_COMPLT_EVT, pairing_bda, &evt_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -984,17 +1000,18 @@ BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb)
|
||||
SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, cmd_code);
|
||||
|
||||
if ((cmd_code > (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */)) ||
|
||||
(cmd_code < SMP_OPCODE_MIN))
|
||||
{
|
||||
(cmd_code < SMP_OPCODE_MIN)) {
|
||||
SMP_TRACE_WARNING("Somehow received command with the RESERVED code 0x%02x\n", cmd_code);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!(*smp_cmd_len_is_valid[cmd_code])(p_cb))
|
||||
if (!(*smp_cmd_len_is_valid[cmd_code])(p_cb)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!(*smp_cmd_param_ranges_are_valid[cmd_code])(p_cb))
|
||||
if (!(*smp_cmd_param_ranges_are_valid[cmd_code])(p_cb)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1016,11 +1033,10 @@ BOOLEAN smp_command_has_valid_fixed_length(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, cmd_code);
|
||||
|
||||
if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code])
|
||||
{
|
||||
if (p_cb->rcvd_cmd_len != smp_cmd_size_per_spec[cmd_code]) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with invalid length\
|
||||
0x%02x (per spec the length is 0x%02x).\n",
|
||||
cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]);
|
||||
cmd_code, p_cb->rcvd_cmd_len, smp_cmd_size_per_spec[cmd_code]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1050,35 +1066,31 @@ BOOLEAN smp_pairing_request_response_parameters_are_valid(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, p_cb->rcvd_cmd_code);
|
||||
|
||||
if (io_caps >= BTM_IO_CAP_MAX)
|
||||
{
|
||||
if (io_caps >= BTM_IO_CAP_MAX) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with IO Capabilty \
|
||||
value (0x%02x) out of range).\n",
|
||||
p_cb->rcvd_cmd_code, io_caps);
|
||||
p_cb->rcvd_cmd_code, io_caps);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!((oob_flag == SMP_OOB_NONE) || (oob_flag == SMP_OOB_PRESENT)))
|
||||
{
|
||||
if (!((oob_flag == SMP_OOB_NONE) || (oob_flag == SMP_OOB_PRESENT))) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with OOB data flag value \
|
||||
(0x%02x) out of range).\n",
|
||||
p_cb->rcvd_cmd_code, oob_flag);
|
||||
p_cb->rcvd_cmd_code, oob_flag);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!((bond_flag == SMP_AUTH_NO_BOND) || (bond_flag == SMP_AUTH_BOND)))
|
||||
{
|
||||
if (!((bond_flag == SMP_AUTH_NO_BOND) || (bond_flag == SMP_AUTH_BOND))) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Bonding_Flags value (0x%02x)\
|
||||
out of range).\n",
|
||||
p_cb->rcvd_cmd_code, bond_flag);
|
||||
p_cb->rcvd_cmd_code, bond_flag);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((enc_size < SMP_ENCR_KEY_SIZE_MIN) || (enc_size > SMP_ENCR_KEY_SIZE_MAX))
|
||||
{
|
||||
if ((enc_size < SMP_ENCR_KEY_SIZE_MIN) || (enc_size > SMP_ENCR_KEY_SIZE_MAX)) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Maximum Encryption \
|
||||
Key value (0x%02x) out of range).\n",
|
||||
p_cb->rcvd_cmd_code, enc_size);
|
||||
p_cb->rcvd_cmd_code, enc_size);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1100,11 +1112,10 @@ BOOLEAN smp_pairing_keypress_notification_is_valid(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, p_cb->rcvd_cmd_code);
|
||||
|
||||
if (keypress_notification >= BTM_SP_KEY_OUT_OF_RANGE)
|
||||
{
|
||||
if (keypress_notification >= BTM_SP_KEY_OUT_OF_RANGE) {
|
||||
SMP_TRACE_WARNING("Rcvd from the peer cmd 0x%02x with Pairing Keypress \
|
||||
Notification value (0x%02x) out of range).\n",
|
||||
p_cb->rcvd_cmd_code, keypress_notification);
|
||||
p_cb->rcvd_cmd_code, keypress_notification);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1152,9 +1163,8 @@ void smp_reject_unexpected_pairing_command(BD_ADDR bd_addr)
|
||||
|
||||
SMP_TRACE_DEBUG ("%s\n", __FUNCTION__);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +\
|
||||
SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + \
|
||||
SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_PAIRING_FAILED);
|
||||
@@ -1190,28 +1200,24 @@ tSMP_ASSO_MODEL smp_select_association_model(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __FUNCTION__);
|
||||
SMP_TRACE_DEBUG("%s p_cb->peer_io_caps = %d p_cb->local_io_capability = %d\n",
|
||||
__FUNCTION__, p_cb->peer_io_caps, p_cb->local_io_capability);
|
||||
__FUNCTION__, p_cb->peer_io_caps, p_cb->local_io_capability);
|
||||
SMP_TRACE_DEBUG("%s p_cb->peer_oob_flag = %d p_cb->loc_oob_flag = %d\n",
|
||||
__FUNCTION__, p_cb->peer_oob_flag, p_cb->loc_oob_flag);
|
||||
__FUNCTION__, p_cb->peer_oob_flag, p_cb->loc_oob_flag);
|
||||
SMP_TRACE_DEBUG("%s p_cb->peer_auth_req = 0x%02x p_cb->loc_auth_req = 0x%02x\n",
|
||||
__FUNCTION__, p_cb->peer_auth_req, p_cb->loc_auth_req);
|
||||
__FUNCTION__, p_cb->peer_auth_req, p_cb->loc_auth_req);
|
||||
SMP_TRACE_DEBUG("%s p_cb->secure_connections_only_mode_required = %s\n",
|
||||
__FUNCTION__, p_cb->secure_connections_only_mode_required ?
|
||||
"TRUE" : "FALSE");
|
||||
__FUNCTION__, p_cb->secure_connections_only_mode_required ?
|
||||
"TRUE" : "FALSE");
|
||||
|
||||
if ((p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT) && (p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT))
|
||||
{
|
||||
if ((p_cb->peer_auth_req & SMP_SC_SUPPORT_BIT) && (p_cb->loc_auth_req & SMP_SC_SUPPORT_BIT)) {
|
||||
p_cb->le_secure_connections_mode_is_used = TRUE;
|
||||
}
|
||||
|
||||
SMP_TRACE_DEBUG("use_sc_process = %d\n", p_cb->le_secure_connections_mode_is_used);
|
||||
|
||||
if (p_cb->le_secure_connections_mode_is_used)
|
||||
{
|
||||
if (p_cb->le_secure_connections_mode_is_used) {
|
||||
model = smp_select_association_model_secure_connections(p_cb);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
model = smp_select_legacy_association_model(p_cb);
|
||||
}
|
||||
return model;
|
||||
@@ -1230,25 +1236,23 @@ tSMP_ASSO_MODEL smp_select_legacy_association_model(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
/* if OOB data is present on both devices, then use OOB association model */
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT)
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) {
|
||||
return SMP_MODEL_OOB;
|
||||
}
|
||||
|
||||
/* else if neither device requires MITM, then use Just Works association model */
|
||||
if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req))
|
||||
if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req)) {
|
||||
return SMP_MODEL_ENCRYPTION_ONLY;
|
||||
}
|
||||
|
||||
/* otherwise use IO capability to select association model */
|
||||
if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX)
|
||||
{
|
||||
if (p_cb->role == HCI_ROLE_MASTER)
|
||||
{
|
||||
if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX) {
|
||||
if (p_cb->role == HCI_ROLE_MASTER) {
|
||||
model = smp_association_table[p_cb->role][p_cb->peer_io_caps]
|
||||
[p_cb->local_io_capability];
|
||||
}
|
||||
else
|
||||
{
|
||||
[p_cb->local_io_capability];
|
||||
} else {
|
||||
model = smp_association_table[p_cb->role][p_cb->local_io_capability]
|
||||
[p_cb->peer_io_caps];
|
||||
[p_cb->peer_io_caps];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1268,25 +1272,23 @@ tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
/* if OOB data is present on at least one device, then use OOB association model */
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT || p_cb->loc_oob_flag == SMP_OOB_PRESENT)
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT || p_cb->loc_oob_flag == SMP_OOB_PRESENT) {
|
||||
return SMP_MODEL_SEC_CONN_OOB;
|
||||
}
|
||||
|
||||
/* else if neither device requires MITM, then use Just Works association model */
|
||||
if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req))
|
||||
if (SMP_NO_MITM_REQUIRED (p_cb->peer_auth_req) && SMP_NO_MITM_REQUIRED(p_cb->loc_auth_req)) {
|
||||
return SMP_MODEL_SEC_CONN_JUSTWORKS;
|
||||
}
|
||||
|
||||
/* otherwise use IO capability to select association model */
|
||||
if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX)
|
||||
{
|
||||
if (p_cb->role == HCI_ROLE_MASTER)
|
||||
{
|
||||
if (p_cb->peer_io_caps < SMP_IO_CAP_MAX && p_cb->local_io_capability < SMP_IO_CAP_MAX) {
|
||||
if (p_cb->role == HCI_ROLE_MASTER) {
|
||||
model = smp_association_table_sc[p_cb->role][p_cb->peer_io_caps]
|
||||
[p_cb->local_io_capability];
|
||||
}
|
||||
else
|
||||
{
|
||||
[p_cb->local_io_capability];
|
||||
} else {
|
||||
model = smp_association_table_sc[p_cb->role][p_cb->local_io_capability]
|
||||
[p_cb->peer_io_caps];
|
||||
[p_cb->peer_io_caps];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1301,15 +1303,14 @@ tSMP_ASSO_MODEL smp_select_association_model_secure_connections(tSMP_CB *p_cb)
|
||||
*******************************************************************************/
|
||||
void smp_reverse_array(UINT8 *arr, UINT8 len)
|
||||
{
|
||||
UINT8 i =0, tmp;
|
||||
UINT8 i = 0, tmp;
|
||||
|
||||
SMP_TRACE_DEBUG("smp_reverse_array\n");
|
||||
|
||||
for (i = 0; i < len/2; i ++)
|
||||
{
|
||||
for (i = 0; i < len / 2; i ++) {
|
||||
tmp = arr[i];
|
||||
arr[i] = arr[len -1 - i];
|
||||
arr[len -1 - i] = tmp;
|
||||
arr[i] = arr[len - 1 - i];
|
||||
arr[len - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1326,8 +1327,8 @@ void smp_reverse_array(UINT8 *arr, UINT8 len)
|
||||
*******************************************************************************/
|
||||
UINT8 smp_calculate_random_input(UINT8 *random, UINT8 round)
|
||||
{
|
||||
UINT8 i = round/8;
|
||||
UINT8 j = round%8;
|
||||
UINT8 i = round / 8;
|
||||
UINT8 j = round % 8;
|
||||
UINT8 ri;
|
||||
|
||||
SMP_TRACE_DEBUG("random: 0x%02x, round: %d, i: %d, j: %d\n", random[i], round, i, j);
|
||||
@@ -1413,8 +1414,7 @@ void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
|
||||
if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, bda, &addr_type))
|
||||
{
|
||||
if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, bda, &addr_type)) {
|
||||
SMP_TRACE_ERROR("can not collect peer le addr information for unknown device\n");
|
||||
return;
|
||||
}
|
||||
@@ -1444,8 +1444,7 @@ BOOLEAN smp_check_commitment(tSMP_CB *p_cb)
|
||||
print128(expected, (const UINT8 *)"calculated peer commitment");
|
||||
print128(p_cb->remote_commitment, (const UINT8 *)"received peer commitment");
|
||||
|
||||
if (memcmp(p_cb->remote_commitment, expected, BT_OCTET16_LEN))
|
||||
{
|
||||
if (memcmp(p_cb->remote_commitment, expected, BT_OCTET16_LEN)) {
|
||||
SMP_TRACE_WARNING("Commitment check fails\n");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1506,23 +1505,19 @@ BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
|
||||
if (p_cb->role == HCI_ROLE_MASTER)
|
||||
{
|
||||
if (p_cb->role == HCI_ROLE_MASTER) {
|
||||
smp_collect_local_ble_address(a, p_cb);
|
||||
smp_collect_peer_ble_address(b, p_cb);
|
||||
p_na = p_cb->rand;
|
||||
p_nb = p_cb->rrand;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
smp_collect_local_ble_address(b, p_cb);
|
||||
smp_collect_peer_ble_address(a, p_cb);
|
||||
p_na = p_cb->rrand;
|
||||
p_nb = p_cb->rand;
|
||||
}
|
||||
|
||||
if(!smp_calculate_f5(p_cb->dhkey, p_na, p_nb, a, b, p_cb->mac_key, p_cb->ltk))
|
||||
{
|
||||
if (!smp_calculate_f5(p_cb->dhkey, p_na, p_nb, a, b, p_cb->mac_key, p_cb->ltk)) {
|
||||
SMP_TRACE_ERROR("%s failed\n", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1547,25 +1542,21 @@ BOOLEAN smp_request_oob_data(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT)
|
||||
{
|
||||
if (p_cb->peer_oob_flag == SMP_OOB_PRESENT && p_cb->loc_oob_flag == SMP_OOB_PRESENT) {
|
||||
/* both local and peer rcvd data OOB */
|
||||
req_oob_type = SMP_OOB_BOTH;
|
||||
}
|
||||
else if (p_cb->peer_oob_flag == SMP_OOB_PRESENT)
|
||||
{
|
||||
} else if (p_cb->peer_oob_flag == SMP_OOB_PRESENT) {
|
||||
/* peer rcvd OOB local data, local didn't receive OOB peer data */
|
||||
req_oob_type = SMP_OOB_LOCAL;
|
||||
}
|
||||
else if (p_cb->loc_oob_flag == SMP_OOB_PRESENT)
|
||||
{
|
||||
} else if (p_cb->loc_oob_flag == SMP_OOB_PRESENT) {
|
||||
req_oob_type = SMP_OOB_PEER;
|
||||
}
|
||||
|
||||
SMP_TRACE_DEBUG("req_oob_type = %d\n", req_oob_type);
|
||||
|
||||
if (req_oob_type == SMP_OOB_INVALID_TYPE)
|
||||
if (req_oob_type == SMP_OOB_INVALID_TYPE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
p_cb->req_oob_type = req_oob_type;
|
||||
p_cb->cb_evt = SMP_SC_OOB_REQ_EVT;
|
||||
|
Reference in New Issue
Block a user