*
******************************************************************************/
-/******************************************************************************
- *
- * This file contains functions that handle ACL connections. This includes
- * operations such as hold and sniff modes, supported packet types.
- *
- ******************************************************************************/
+/*****************************************************************************
+**
+** Name: btm_acl.c
+**
+** Description: This file contains functions that handle ACL connections.
+** This includes operations such as hold and sniff modes,
+** supported packet types.
+**
+** This module contains both internal and external (API)
+** functions. External (API) functions are distinguishable
+** by their names beginning with uppercase BTM.
+**
+**
+******************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "bt_types.h"
#include "bt_target.h"
+#include "device/include/controller.h"
#include "gki.h"
#include "hcimsgs.h"
#include "btu.h"
#include "btm_int.h"
#include "l2c_int.h"
#include "hcidefs.h"
-#include "bd.h"
#include "bt_utils.h"
static void btm_read_remote_features (UINT16 handle);
static void btm_read_remote_ext_features (UINT16 handle, UINT8 page_number);
-static void btm_process_remote_ext_features_page (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec,
- UINT8 page_idx);
static void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages);
#define BTM_DEV_REPLY_TIMEOUT 3 /* 3 second timeout waiting for responses */
/*******************************************************************************
**
-** Function btm_save_remote_device_role
-**
-** Description This function is to save remote device role
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_save_remote_device_role(BD_ADDR bd_addr, UINT8 role)
-{
- UINT8 i, j;
- if (role == BTM_ROLE_UNDEFINED) return;
-
- for (i = 0; i < BTM_ROLE_DEVICE_NUM; i++) {
- if ((btm_cb.previous_connected_role[i] != BTM_ROLE_UNDEFINED) &&
- (!bdcmp(bd_addr, btm_cb.previous_connected_remote_addr[i]))) {
- break;
- }
- }
-
- if (i < BTM_ROLE_DEVICE_NUM) {
- UINT8 end;
- if (i < btm_cb.front) {
- for (j = i; j > 0; j--) {
- bdcpy(btm_cb.previous_connected_remote_addr[j],
- btm_cb.previous_connected_remote_addr[j-1]);
- }
- bdcpy(btm_cb.previous_connected_remote_addr[0],
- btm_cb.previous_connected_remote_addr[BTM_ROLE_DEVICE_NUM-1]);
- end = BTM_ROLE_DEVICE_NUM-1;
- } else {
- end = i;
- }
-
- for (j = end; j > btm_cb.front; j--) {
- bdcpy(btm_cb.previous_connected_remote_addr[j],
- btm_cb.previous_connected_remote_addr[j-1]);
- }
- }
-
- bdcpy(btm_cb.previous_connected_remote_addr[btm_cb.front], bd_addr);
- btm_cb.previous_connected_role[btm_cb.front] = role;
- btm_cb.front = (btm_cb.front + 1) % BTM_ROLE_DEVICE_NUM;
-}
-
-/*******************************************************************************
-**
** Function btm_acl_init
**
** Description This function is called at BTM startup to initialize
BTM_TRACE_DEBUG ("btm_acl_init");
#if 0 /* cleared in btm_init; put back in if called from anywhere else! */
memset (&btm_cb.acl_db, 0, sizeof (btm_cb.acl_db));
-#if RFCOMM_INCLUDED == TRUE
memset (btm_cb.btm_scn, 0, BTM_MAX_SCN); /* Initialize the SCN usage to FALSE */
-#endif
btm_cb.btm_def_link_policy = 0;
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
btm_cb.p_bl_changed_cb = NULL;
-#else
- btm_cb.p_acl_changed_cb = NULL;
-#endif
#endif
/* Initialize nonzero defaults */
UINT16 hci_handle, UINT8 link_role, tBT_TRANSPORT transport)
{
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
- UINT8 yy;
tACL_CONN *p;
UINT8 xx;
{
p->hci_handle = hci_handle;
p->link_role = link_role;
- btm_save_remote_device_role(bda, link_role);
#if BLE_INCLUDED == TRUE
p->transport = transport;
#endif
p->in_use = TRUE;
p->hci_handle = hci_handle;
p->link_role = link_role;
- btm_save_remote_device_role(bda, link_role);
p->link_up_issued = FALSE;
+ memcpy (p->remote_addr, bda, BD_ADDR_LEN);
#if BLE_INCLUDED == TRUE
p->transport = transport;
- if (transport == BT_TRANSPORT_LE)
- {
#if BLE_PRIVACY_SPT == TRUE
- if (btm_cb.ble_ctr_cb.privacy)
- {
- p->conn_addr_type = btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type;
- memcpy(p->conn_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, BD_ADDR_LEN);
- }
- else
+ if (transport == BT_TRANSPORT_LE)
+ btm_ble_refresh_local_resolvable_private_addr(bda,
+ btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
#endif
- {
- p->conn_addr_type = BLE_ADDR_PUBLIC;
- BTM_GetLocalDeviceAddr(p->conn_addr);
- }
- }
#endif
- p->restore_pkt_types = 0; /* Only exists while SCO is active */
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
-#if BTM_PWR_MGR_INCLUDED == FALSE
- p->mode = BTM_ACL_MODE_NORMAL;
-#else
btm_pm_sm_alloc(xx);
-#endif /* BTM_PWR_MGR_INCLUDED == FALSE */
- memcpy (p->remote_addr, bda, BD_ADDR_LEN);
if (dc)
memcpy (p->remote_dc, dc, DEV_CLASS_LEN);
{
/* If remote features already known, copy them and continue connection setup */
if ((p_dev_rec->num_read_pages) &&
- (p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1)) /* sanity check */)
+ (p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1)))
{
memcpy (p->peer_lmp_features, p_dev_rec->features,
(HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages));
p->num_read_pages = p_dev_rec->num_read_pages;
- if (BTM_SEC_MODE_SP == btm_cb.security_mode
- && HCI_SSP_HOST_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_1])
- && HCI_SIMPLE_PAIRING_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0]))
- {
- p_dev_rec->sm4 = BTM_SM4_TRUE;
- }
- else
+ const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
+
+ /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
+ btm_sec_set_peer_sec_caps(p, p_dev_rec);
+
+ BTM_TRACE_API("%s: pend:%d", __FUNCTION__, req_pend);
+ if (req_pend)
{
- p_dev_rec->sm4 |= BTM_SM4_KNOWN;
+ /* Request for remaining Security Features (if any) */
+ l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
}
-
btm_establish_continue (p);
return;
}
&p->active_remote_addr_type);
#endif
- if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features)
+ if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)
|| link_role == HCI_ROLE_MASTER)
{
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
{
tACL_CONN *p;
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_EVENT_DATA evt_data;
-#endif
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
tBTM_SEC_DEV_REC *p_dev_rec=NULL;
#endif
-
BTM_TRACE_DEBUG ("btm_acl_removed");
p = btm_bda_to_acl(bda, transport);
if (p != (tACL_CONN *)NULL)
p->link_up_issued = FALSE;
/* If anyone cares, tell him database changed */
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
if (btm_cb.p_bl_changed_cb)
{
evt_data.event = BTM_BL_DISCN_EVT;
}
btm_acl_update_busy_level (BTM_BLI_ACL_DOWN_EVT);
-#else
- if (btm_cb.p_acl_changed_cb)
-#if BLE_INCLUDED == TRUE
- (*btm_cb.p_acl_changed_cb) (bda, NULL, NULL, NULL, FALSE, p->hci_handle, p->transport);
-#else
- (*btm_cb.p_acl_changed_cb) (bda, NULL, NULL, NULL, FALSE);
-#endif
-#endif
}
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
}
}
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btm_acl_update_busy_level
{
case BTM_BLI_ACL_UP_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_ACL_UP_EVT");
- btm_cb.num_acl++;
break;
case BTM_BLI_ACL_DOWN_EVT:
- if (btm_cb.num_acl)
- {
- btm_cb.num_acl--;
- BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT", btm_cb.num_acl);
- }
- else
- {
- BTM_TRACE_ERROR ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!");
- }
+ BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT");
break;
case BTM_BLI_PAGE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT");
if (btm_cb.is_paging || btm_cb.is_inquiry)
busy_level = 10;
else
- busy_level = (UINT8)btm_cb.num_acl;
+ busy_level = BTM_GetNumAclLinks();
if ((busy_level != btm_cb.busy_level) ||(old_inquiry_state != btm_cb.is_inquiry))
{
}
}
}
-#endif
-
/*******************************************************************************
**
#if BTM_SCO_INCLUDED == TRUE
BOOLEAN is_sco_active;
#endif
-#if BTM_PWR_MGR_INCLUDED == TRUE
tBTM_STATUS status;
tBTM_PM_MODE pwr_mode;
tBTM_PM_PWR_MD settings;
-#endif
#if (BT_USE_TRACES == TRUE)
BD_ADDR_PTR p_bda;
#endif
remote_bd_addr[3], remote_bd_addr[4], remote_bd_addr[5]);
/* Make sure the local device supports switching */
- if (!(HCI_SWITCH_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])))
+ if (!controller_get_interface()->supports_master_slave_role_switch())
return(BTM_MODE_UNSUPPORTED);
if (btm_cb.devcb.p_switch_role_cb && p_cb)
return(BTM_BUSY);
}
- /* Cannot switch role while parked or sniffing */
-#if BTM_PWR_MGR_INCLUDED == FALSE
- if (p->mode == HCI_MODE_PARK)
- {
- if (!btsnd_hcic_exit_park_mode (p->hci_handle))
- return(BTM_NO_RESOURCES);
-
- p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE;
- }
- else if (p->mode == HCI_MODE_SNIFF)
- {
- if (!btsnd_hcic_exit_sniff_mode (p->hci_handle))
- return(BTM_NO_RESOURCES);
-
- p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE;
- }
-#else /* power manager is in use */
-
if ((status = BTM_ReadPowerMode(p->remote_addr, &pwr_mode)) != BTM_SUCCESS)
return(status);
p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE;
}
-#endif
/* some devices do not support switch while encryption is on */
else
{
/*******************************************************************************
**
-** Function BTM_ChangeLinkKey
-**
-** Description This function is called to change the link key of the
-** connection.
-**
-** Returns BTM_CMD_STARTED if command issued to controller.
-** BTM_NO_RESOURCES if couldn't allocate memory to issue command
-** BTM_UNKNOWN_ADDR if no active link with bd addr specified
-** BTM_BUSY if the previous command is not completed
-**
-*******************************************************************************/
-tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr, tBTM_CMPL_CB *p_cb)
-{
- tACL_CONN *p;
- tBTM_SEC_DEV_REC *p_dev_rec = NULL;
-#if BTM_PWR_MGR_INCLUDED == TRUE
- tBTM_STATUS status;
- tBTM_PM_MODE pwr_mode;
- tBTM_PM_PWR_MD settings;
-#endif
- BTM_TRACE_DEBUG ("BTM_ChangeLinkKey");
- if ((p = btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR)) == NULL)
- return(BTM_UNKNOWN_ADDR);
-
- /* Ignore change link key request if the previsous request has not completed */
- if (p->change_key_state != BTM_ACL_SWKEY_STATE_IDLE)
- {
- BTM_TRACE_DEBUG ("Link key change request declined since the previous request"
- " for this device has not completed ");
- return(BTM_BUSY);
- }
-
- memset (&btm_cb.devcb.chg_link_key_ref_data, 0, sizeof(tBTM_CHANGE_KEY_CMPL));
-
- /* Cannot change key while parked */
-#if BTM_PWR_MGR_INCLUDED == FALSE
- if (p->mode == HCI_MODE_PARK)
- {
- if (!btsnd_hcic_exit_park_mode (p->hci_handle))
- return(BTM_NO_RESOURCES);
-
- p->change_key_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE;
- }
-#else /* power manager is in use */
-
-
- if ((status = BTM_ReadPowerMode(p->remote_addr, &pwr_mode)) != BTM_SUCCESS)
- return(status);
-
- /* Wake up the link if in park before attempting to change link keys */
- if (pwr_mode == BTM_PM_MD_PARK)
- {
- memset( (void*)&settings, 0, sizeof(settings));
- settings.mode = BTM_PM_MD_ACTIVE;
- status = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p->remote_addr, &settings);
- if (status != BTM_CMD_STARTED)
- return(BTM_WRONG_MODE);
-
- p->change_key_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE;
- }
-#endif
- /* some devices do not support change of link key while encryption is on */
- else if (((p_dev_rec = btm_find_dev (remote_bd_addr)) != NULL)
- && ((p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) != 0) && !BTM_EPR_AVAILABLE(p))
- {
- /* bypass turning off encryption if switch role is already doing it */
- if (p->encrypt_state != BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF)
- {
- if (!btsnd_hcic_set_conn_encrypt (p->hci_handle, FALSE))
- return(BTM_NO_RESOURCES);
- else
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF;
- }
-
- p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF;
- }
- else /* Ok to initiate change of link key */
- {
- if (!btsnd_hcic_change_link_key (p->hci_handle))
- return(BTM_NO_RESOURCES);
-
- p->change_key_state = BTM_ACL_SWKEY_STATE_IN_PROGRESS;
- }
-
- /* Initialize return structure in case request fails */
- memcpy (btm_cb.devcb.chg_link_key_ref_data.remote_bd_addr, remote_bd_addr,
- BD_ADDR_LEN);
- btm_cb.devcb.p_chg_link_key_cb = p_cb;
- return(BTM_CMD_STARTED);
-}
-
-/*******************************************************************************
-**
-** Function btm_acl_link_key_change
-**
-** Description This function is called to when a change link key event
-** is received.
-**
-*******************************************************************************/
-void btm_acl_link_key_change (UINT16 handle, UINT8 status)
-{
- tBTM_CHANGE_KEY_CMPL *p_data;
- tACL_CONN *p;
- UINT8 xx;
- BTM_TRACE_DEBUG ("btm_acl_link_key_change");
- /* Look up the connection by handle and set the current mode */
- xx = btm_handle_to_acl_index(handle);
-
- /* don't assume that we can never get a bad hci_handle */
- if (xx >= MAX_L2CAP_LINKS)
- return;
-
- p_data = &btm_cb.devcb.chg_link_key_ref_data;
- p = &btm_cb.acl_db[xx];
- p_data->hci_status = status;
-
- /* if switching state is switching we need to turn encryption on */
- /* if idle, we did not change encryption */
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_SWITCHING)
- {
- /* Make sure there's not also a role switch going on before re-enabling */
- if (p->switch_role_state != BTM_ACL_SWKEY_STATE_SWITCHING)
- {
- if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE))
- {
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON;
- p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
- return;
- }
- }
- else /* Set the state and wait for change link key */
- {
- p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
- return;
- }
- }
-
- /* Set the switch_role_state to IDLE since the reply received from HCI */
- /* regardless of its result either success or failed. */
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_IN_PROGRESS)
- {
- p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE;
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
- }
-
- if (btm_cb.devcb.p_chg_link_key_cb)
- {
- (*btm_cb.devcb.p_chg_link_key_cb)((void *)p_data);
- btm_cb.devcb.p_chg_link_key_cb = NULL;
- }
-
- BTM_TRACE_ERROR("Change Link Key Complete Event: Handle 0x%02x, HCI Status 0x%02x",
- handle, p_data->hci_status);
-}
-
-/*******************************************************************************
-**
** Function btm_acl_encrypt_change
**
** Description This function is when encryption of the connection is
tACL_CONN *p;
UINT8 xx;
tBTM_SEC_DEV_REC *p_dev_rec;
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_ROLE_CHG_DATA evt;
-#endif
BTM_TRACE_DEBUG ("btm_acl_encrypt_change handle=%d status=%d encr_enabl=%d",
handle, status, encr_enable);
p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
btm_acl_report_role_change(btm_cb.devcb.switch_role_ref_data.hci_status, p->remote_addr);
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
/* if role change event is registered, report it now */
if (btm_cb.p_bl_changed_cb && (btm_cb.bl_evt_mask & BTM_BL_ROLE_CHG_MASK))
{
BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
evt.new_role, evt.hci_status, p->switch_role_state);
}
-#endif
#if BTM_DISC_DURING_RS == TRUE
/* If a disconnect is pending, issue it now that role switch has completed */
}
#endif
}
-
-
- /* Process Change Link Key if active */
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF)
- {
- /* if encryption turn off failed we still will try to change link key */
- if (encr_enable)
- {
- p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE;
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
- }
- else
- {
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_TEMP_FUNC;
- p->change_key_state = BTM_ACL_SWKEY_STATE_SWITCHING;
- }
-
- if (!btsnd_hcic_change_link_key (p->hci_handle))
- {
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
- p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE;
- if (btm_cb.devcb.p_chg_link_key_cb)
- {
- (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data);
- btm_cb.devcb.p_chg_link_key_cb = NULL;
- }
- }
- }
- /* Finished enabling Encryption after changing link key */
- else if (p->change_key_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_ON)
- {
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
- p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE;
- if (btm_cb.devcb.p_chg_link_key_cb)
- {
- (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data);
- btm_cb.devcb.p_chg_link_key_cb = NULL;
- }
- }
}
/*******************************************************************************
**
btsnd_hcic_write_def_policy_set(settings);
}
-
/*******************************************************************************
**
-** Function BTM_ReadLinkPolicy
+** Function btm_read_remote_version_complete
**
-** Description This function is called to read the link policy settings.
-** The address of link policy results are returned in the callback.
-** (tBTM_LNK_POLICY_RESULTS)
+** Description This function is called when the command complete message
+** is received from the HCI for the remote version info.
**
-** Returns status of the operation
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
+void btm_read_remote_version_complete (UINT8 *p)
{
- tACL_CONN *p;
-
- BTM_TRACE_API ("BTM_ReadLinkPolicy: RemBdAddr: %02x%02x%02x%02x%02x%02x",
- remote_bda[0], remote_bda[1], remote_bda[2],
- remote_bda[3], remote_bda[4], remote_bda[5]);
-
- /* If someone already waiting on the version, do not allow another */
- if (btm_cb.devcb.p_rlinkp_cmpl_cb)
- return(BTM_BUSY);
-
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
+ tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
+ UINT8 status;
+ UINT16 handle;
+ int xx;
+ BTM_TRACE_DEBUG ("btm_read_remote_version_complete");
+ STREAM_TO_UINT8 (status, p);
+ if (status == HCI_SUCCESS)
{
- btu_start_timer (&btm_cb.devcb.rlinkp_timer, BTU_TTYPE_BTM_ACL, BTM_DEV_REPLY_TIMEOUT);
- btm_cb.devcb.p_rlinkp_cmpl_cb = p_cb;
+ STREAM_TO_UINT16 (handle, p);
- if (!btsnd_hcic_read_policy_set (p->hci_handle))
+ /* Look up the connection by handle and copy features */
+ for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
{
- btu_stop_timer (&btm_cb.devcb.rlinkp_timer);
- btm_cb.devcb.p_rlinkp_cmpl_cb = NULL;
- return(BTM_NO_RESOURCES);
+ if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
+ {
+ STREAM_TO_UINT8 (p_acl_cb->lmp_version, p);
+ STREAM_TO_UINT16 (p_acl_cb->manufacturer, p);
+ STREAM_TO_UINT16 (p_acl_cb->lmp_subversion, p);
+ break;
+ }
}
-
- return(BTM_CMD_STARTED);
}
-
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
}
/*******************************************************************************
**
-** Function btm_read_link_policy_complete
+** Function btm_process_remote_ext_features
**
-** Description This function is called when the command complete message
-** is received from the HCI for the read local link policy request.
+** Description Local function called to process all extended features pages
+** read from a remote device.
**
** Returns void
**
*******************************************************************************/
-void btm_read_link_policy_complete (UINT8 *p)
+void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
{
- tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb;
- tBTM_LNK_POLICY_RESULTS lnkpol;
- UINT16 handle;
- tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
- UINT16 index;
- BTM_TRACE_DEBUG ("btm_read_link_policy_complete");
- btu_stop_timer (&btm_cb.devcb.rlinkp_timer);
+ UINT16 handle = p_acl_cb->hci_handle;
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
+ UINT8 page_idx;
- /* If there was a callback address for read local version, call it */
- btm_cb.devcb.p_rlinkp_cmpl_cb = NULL;
+ BTM_TRACE_DEBUG ("btm_process_remote_ext_features");
- if (p_cb)
- {
- STREAM_TO_UINT8 (lnkpol.hci_status, p);
-
- if (lnkpol.hci_status == HCI_SUCCESS)
- {
- lnkpol.status = BTM_SUCCESS;
-
- STREAM_TO_UINT16 (handle, p);
-
- STREAM_TO_UINT16 (lnkpol.settings, p);
-
- /* Search through the list of active channels for the correct BD Addr */
- for (index = 0; index < MAX_L2CAP_LINKS; index++, p_acl_cb++)
- {
- if ((p_acl_cb->in_use) && (handle == p_acl_cb->hci_handle))
- {
- memcpy (lnkpol.rem_bda, p_acl_cb->remote_addr, BD_ADDR_LEN);
- break;
- }
- }
- }
- else
- lnkpol.status = BTM_ERR_PROCESSING;
-
- (*p_cb)(&lnkpol);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function btm_read_remote_version_complete
-**
-** Description This function is called when the command complete message
-** is received from the HCI for the remote version info.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_remote_version_complete (UINT8 *p)
-{
- tACL_CONN *p_acl_cb = &btm_cb.acl_db[0];
- UINT8 status;
- UINT16 handle;
- int xx;
- BTM_TRACE_DEBUG ("btm_read_remote_version_complete");
- STREAM_TO_UINT8 (status, p);
- if (status == HCI_SUCCESS)
- {
- STREAM_TO_UINT16 (handle, p);
-
- /* Look up the connection by handle and copy features */
- for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl_cb++)
- {
- if ((p_acl_cb->in_use) && (p_acl_cb->hci_handle == handle))
- {
- STREAM_TO_UINT8 (p_acl_cb->lmp_version, p);
- STREAM_TO_UINT16 (p_acl_cb->manufacturer, p);
- STREAM_TO_UINT16 (p_acl_cb->lmp_subversion, p);
- break;
- }
- }
- }
-}
-
-
-/*******************************************************************************
-**
-** Function btm_process_remote_ext_features
-**
-** Description Local function called to process all extended features pages
-** read from a remote device.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
-{
- UINT16 handle = p_acl_cb->hci_handle;
- tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle);
- UINT8 page_idx;
-
- BTM_TRACE_DEBUG ("btm_process_remote_ext_features");
-
- /* Make sure we have the record to save remote features information */
- if (p_dev_rec == NULL)
+ /* Make sure we have the record to save remote features information */
+ if (p_dev_rec == NULL)
{
/* Get a new device; might be doing dedicated bonding */
p_dev_rec = btm_find_or_alloc_dev (p_acl_cb->remote_addr);
p_acl_cb->num_read_pages = num_read_pages;
p_dev_rec->num_read_pages = num_read_pages;
- /* Process the pages one by one */
+ /* Move the pages to placeholder */
for (page_idx = 0; page_idx < num_read_pages; page_idx++)
{
- btm_process_remote_ext_features_page (p_acl_cb, p_dev_rec, page_idx);
- }
-}
-
-
-/*******************************************************************************
-**
-** Function btm_process_remote_ext_features_page
-**
-** Description Local function called to process the information located
-** in the specific extended features page read from a remote device.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_process_remote_ext_features_page (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec,
- UINT8 page_idx)
-{
- UINT16 handle;
- UINT8 req_pend;
-
- handle = p_acl_cb->hci_handle;
-
- memcpy (p_dev_rec->features[page_idx], p_acl_cb->peer_lmp_features[page_idx],
- HCI_FEATURE_BYTES_PER_PAGE);
-
- switch (page_idx)
- {
- /* Extended (Legacy) Page 0 */
- case HCI_EXT_FEATURES_PAGE_0:
- /* Page 0 indicates Controller support for SSP */
- if (btm_cb.security_mode < BTM_SEC_MODE_SP ||
- !HCI_SIMPLE_PAIRING_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0]))
- {
- req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
- p_dev_rec->sm4 = BTM_SM4_KNOWN;
- if (req_pend)
- {
- l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
- }
- }
- break;
-
- /* Extended Page 1 */
- case HCI_EXT_FEATURES_PAGE_1:
- /* Page 1 indicates Host support for SSP and SC */
- req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
-
- if (btm_cb.security_mode == BTM_SEC_MODE_SP
- && HCI_SSP_HOST_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_1])
- && HCI_SIMPLE_PAIRING_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0]))
+ if (page_idx > HCI_EXT_FEATURES_PAGE_MAX)
{
- p_dev_rec->sm4 = BTM_SM4_TRUE;
- }
- else
- {
- p_dev_rec->sm4 = BTM_SM4_KNOWN;
+ BTM_TRACE_ERROR("%s: page=%d unexpected", __FUNCTION__, page_idx);
+ break;
}
+ memcpy (p_dev_rec->features[page_idx], p_acl_cb->peer_lmp_features[page_idx],
+ HCI_FEATURE_BYTES_PER_PAGE);
+ }
- BTM_TRACE_API ("ext_features_complt page_num:%d f[0]:x%02x, sm4:%x, pend:%d",
- HCI_EXT_FEATURES_PAGE_1, *(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_1]),
- p_dev_rec->sm4, req_pend);
-
- if (req_pend)
- l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
-
- break;
+ const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
- /* Extended Page 2 */
- case HCI_EXT_FEATURES_PAGE_2:
- /* Page 2 indicates Ping support*/
- break;
+ /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
+ btm_sec_set_peer_sec_caps(p_acl_cb, p_dev_rec);
- default:
- BTM_TRACE_ERROR("btm_process_remote_ext_features_page page=%d unexpected", page_idx);
- break;
+ BTM_TRACE_API("%s: pend:%d", __FUNCTION__, req_pend);
+ if (req_pend)
+ {
+ /* Request for remaining Security Features (if any) */
+ l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
}
}
HCI_FEATURE_BYTES_PER_PAGE);
if ((HCI_LMP_EXTENDED_SUPPORTED(p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) &&
- (HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(btm_cb.devcb.supported_cmds)))
+ (controller_get_interface()->supports_reading_remote_extended_features()))
{
/* if the remote controller has extended features and local controller supports
** HCI_Read_Remote_Extended_Features command then start reading these feature starting
void btm_read_remote_ext_features_complete (UINT8 *p)
{
tACL_CONN *p_acl_cb;
- UINT8 status, page_num, max_page;
+ UINT8 page_num, max_page;
UINT16 handle;
UINT8 acl_idx;
BTM_TRACE_DEBUG ("btm_read_remote_ext_features_complete");
- STREAM_TO_UINT8 (status, p);
+ ++p;
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (page_num, p);
STREAM_TO_UINT8 (max_page, p);
** Description This function is called when the remote extended features
** complete event returns a failed status.
**
-** Returns void
-**
-*******************************************************************************/
-void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle)
-{
- tACL_CONN *p_acl_cb;
- UINT8 acl_idx;
-
- BTM_TRACE_WARNING ("btm_read_remote_ext_features_failed (status 0x%02x) for handle %d",
- status, handle);
-
- if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
- {
- BTM_TRACE_ERROR("btm_read_remote_ext_features_failed handle=%d invalid", handle);
- return;
- }
-
- p_acl_cb = &btm_cb.acl_db[acl_idx];
-
- /* Process supported features only */
- btm_process_remote_ext_features (p_acl_cb, 1);
-
- /* Continue HCI connection establishment */
- btm_establish_continue (p_acl_cb);
-}
-
-/*******************************************************************************
-**
-** Function btm_establish_continue
-**
-** Description This function is called when the command complete message
-** is received from the HCI for the read local link policy request.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_establish_continue (tACL_CONN *p_acl_cb)
-{
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
- tBTM_BL_EVENT_DATA evt_data;
-#endif
- BTM_TRACE_DEBUG ("btm_establish_continue");
-#if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
-#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
- if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
-#endif
- {
- /* For now there are a some devices that do not like sending */
- /* commands events and data at the same time. */
- /* Set the packet types to the default allowed by the device */
- btm_set_packet_types (p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
-
- if (btm_cb.btm_def_link_policy)
- BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
- }
-#endif
- p_acl_cb->link_up_issued = TRUE;
-
- /* If anyone cares, tell him database changed */
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
- if (btm_cb.p_bl_changed_cb)
- {
- evt_data.event = BTM_BL_CONN_EVT;
- evt_data.conn.p_bda = p_acl_cb->remote_addr;
- evt_data.conn.p_bdn = p_acl_cb->remote_name;
- evt_data.conn.p_dc = p_acl_cb->remote_dc;
- evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0];
-#if BLE_INCLUDED == TRUE
- evt_data.conn.handle = p_acl_cb->hci_handle;
- evt_data.conn.transport = p_acl_cb->transport;
-#endif
-
- (*btm_cb.p_bl_changed_cb)(&evt_data);
- }
- btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT);
-#else
- if (btm_cb.p_acl_changed_cb)
-#if BLE_INCLUDED == TRUE
- (*btm_cb.p_acl_changed_cb) (p_acl_cb->remote_addr,
- p_acl_cb->remote_dc,
- p_acl_cb->remote_name,
- p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0],
- TRUE,
- p_acl_cb->hci_handle,
- p_acl_cb->transport);
-#else
- (*btm_cb.p_acl_changed_cb) (p_acl_cb->remote_addr,
- p_acl_cb->remote_dc,
- p_acl_cb->remote_name,
- p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0],
- TRUE);
-#endif
-
-#endif
-
-}
-
-
-/*******************************************************************************
-**
-** Function BTM_SetDefaultLinkSuperTout
-**
-** Description Set the default value for HCI "Write Link Supervision Timeout"
-** command to use when an ACL link is created.
-**
-** Returns void
-**
-*******************************************************************************/
-void BTM_SetDefaultLinkSuperTout (UINT16 timeout)
-{
- BTM_TRACE_DEBUG ("BTM_SetDefaultLinkSuperTout");
- btm_cb.btm_def_link_super_tout = timeout;
-}
-
-/*******************************************************************************
-**
-** Function BTM_GetLinkSuperTout
-**
-** Description Read the link supervision timeout value of the connection
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda, UINT16 *p_timeout)
-{
- tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
-
- BTM_TRACE_DEBUG ("BTM_GetLinkSuperTout");
- if (p != (tACL_CONN *)NULL)
- {
- *p_timeout = p->link_super_tout;
- return(BTM_SUCCESS);
- }
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
-}
-
-
-/*******************************************************************************
-**
-** Function BTM_SetLinkSuperTout
-**
-** Description Create and send HCI "Write Link Supervision Timeout" command
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda, UINT16 timeout)
-{
- tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
-
- BTM_TRACE_DEBUG ("BTM_SetLinkSuperTout");
- if (p != (tACL_CONN *)NULL)
- {
- p->link_super_tout = timeout;
-
- /* Only send if current role is Master; 2.0 spec requires this */
- if (p->link_role == BTM_ROLE_MASTER)
- {
- if (!btsnd_hcic_write_link_super_tout (LOCAL_BR_EDR_CONTROLLER_ID,
- p->hci_handle, timeout))
- return(BTM_NO_RESOURCES);
-
- return(BTM_CMD_STARTED);
- }
- else
- return(BTM_SUCCESS);
- }
-
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
-}
-
-/*******************************************************************************
-**
-** Function BTM_RegForLstoEvt
-**
-** Description register for the HCI "Link Supervision Timeout Change" event
-**
-** Returns void
-**
-*******************************************************************************/
-void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback)
-{
- BTM_TRACE_DEBUG ("BTM_RegForLstoEvt");
- btm_cb.p_lsto_cback = p_cback;
-}
-
-/*******************************************************************************
-**
-** Function btm_proc_lsto_evt
-**
-** Description process the HCI "Link Supervision Timeout Change" event
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_proc_lsto_evt(UINT16 handle, UINT16 timeout)
-{
- UINT8 xx;
-
- BTM_TRACE_DEBUG ("btm_proc_lsto_evt");
- if (btm_cb.p_lsto_cback)
- {
- /* Look up the connection by handle and set the current mode */
- xx = btm_handle_to_acl_index(handle);
-
- /* don't assume that we can never get a bad hci_handle */
- if (xx < MAX_L2CAP_LINKS)
- {
- (*btm_cb.p_lsto_cback)(btm_cb.acl_db[xx].remote_addr, timeout);
- }
- }
-}
-
-#if BTM_PWR_MGR_INCLUDED == FALSE
-/*******************************************************************************
-**
-** Function BTM_SetHoldMode
-**
-** Description This function is called to set a connection into hold mode.
-** A check is made if the connection is in sniff or park mode,
-** and if yes, the hold mode is ignored.
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval, UINT16 max_interval)
-{
- tACL_CONN *p;
-
- BTM_TRACE_DEBUG ("BTM_SetHoldMode");
- /* First, check if hold mode is supported */
- if (!HCI_HOLD_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
- return(BTM_MODE_UNSUPPORTED);
-
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
- {
- /* If the connection is in park or sniff mode, forget about holding it */
- if (p->mode != BTM_ACL_MODE_NORMAL)
- return(BTM_SUCCESS);
-
- if (!btsnd_hcic_hold_mode (p->hci_handle, max_interval, min_interval))
- return(BTM_NO_RESOURCES);
-
- return(BTM_CMD_STARTED);
- }
-
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
-}
-
-
-/*******************************************************************************
-**
-** Function BTM_SetSniffMode
-**
-** Description This function is called to set a connection into sniff mode.
-** A check is made if the connection is already in sniff or park
-** mode, and if yes, the sniff mode is ignored.
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period, UINT16 max_period,
- UINT16 attempt, UINT16 timeout)
-{
- tACL_CONN *p;
- BTM_TRACE_DEBUG ("BTM_SetSniffMode");
- /* First, check if sniff mode is supported */
- if (!HCI_SNIFF_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
- return(BTM_MODE_UNSUPPORTED);
-
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
- {
- /* If the connection is in park mode, forget about sniffing it */
- if (p->mode != BTM_ACL_MODE_NORMAL)
- return(BTM_WRONG_MODE);
-
- if (!btsnd_hcic_sniff_mode (p->hci_handle, max_period,
- min_period, attempt, timeout))
- return(BTM_NO_RESOURCES);
-
- return(BTM_CMD_STARTED);
- }
-
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
-}
-
-
-
-
-/*******************************************************************************
-**
-** Function BTM_CancelSniffMode
-**
-** Description This function is called to put a connection out of sniff mode.
-** A check is made if the connection is already in sniff mode,
-** and if not, the cancel sniff mode is ignored.
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda)
-{
- tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_DEBUG ("BTM_CancelSniffMode ");
- if (p == (tACL_CONN *)NULL)
- return(BTM_UNKNOWN_ADDR);
-
- /* If the connection is not in sniff mode, cannot cancel */
- if (p->mode != BTM_ACL_MODE_SNIFF)
- return(BTM_WRONG_MODE);
-
- if (!btsnd_hcic_exit_sniff_mode (p->hci_handle))
- return(BTM_NO_RESOURCES);
-
- return(BTM_CMD_STARTED);
-}
-
-
-/*******************************************************************************
-**
-** Function BTM_SetParkMode
-**
-** Description This function is called to set a connection into park mode.
-** A check is made if the connection is already in sniff or park
-** mode, and if yes, the park mode is ignored.
-**
-** Returns status of the operation
-**
-*******************************************************************************/
-tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda, UINT16 beacon_min_period, UINT16 beacon_max_period)
-{
- tACL_CONN *p;
-
- BTM_TRACE_DEBUG ("BTM_SetParkMode");
- /* First, check if park mode is supported */
- if (!HCI_PARK_MODE_SUPPORTED(BTM_ReadLocalFeatures()))
- return(BTM_MODE_UNSUPPORTED);
-
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
- {
- /* If the connection is in sniff mode, forget about parking it */
- if (p->mode != BTM_ACL_MODE_NORMAL)
- return(BTM_WRONG_MODE);
-
- /* no park mode if SCO exists -- CR#1982, 1.1 errata 1124
- command status event should be returned /w error code 0x0C "Command Disallowed"
- Let LM do this.
- */
- if (!btsnd_hcic_park_mode (p->hci_handle,
- beacon_max_period, beacon_min_period))
- return(BTM_NO_RESOURCES);
-
- return(BTM_CMD_STARTED);
- }
-
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
-}
-
-/*******************************************************************************
-**
-** Function BTM_CancelParkMode
-**
-** Description This function is called to put a connection out of park mode.
-** A check is made if the connection is already in park mode,
-** and if not, the cancel sniff mode is ignored.
-**
-** Returns status of the operation
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda)
+void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle)
{
- tACL_CONN *p;
+ tACL_CONN *p_acl_cb;
+ UINT8 acl_idx;
- BTM_TRACE_DEBUG ("BTM_CancelParkMode");
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
+ BTM_TRACE_WARNING ("btm_read_remote_ext_features_failed (status 0x%02x) for handle %d",
+ status, handle);
+
+ if ((acl_idx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS)
{
- /* If the connection is not in park mode, cannot cancel */
- if (p->mode != BTM_ACL_MODE_PARK)
- return(BTM_WRONG_MODE);
+ BTM_TRACE_ERROR("btm_read_remote_ext_features_failed handle=%d invalid", handle);
+ return;
+ }
- if (!btsnd_hcic_exit_park_mode (p->hci_handle))
- return(BTM_NO_RESOURCES);
+ p_acl_cb = &btm_cb.acl_db[acl_idx];
- return(BTM_CMD_STARTED);
- }
+ /* Process supported features only */
+ btm_process_remote_ext_features (p_acl_cb, 1);
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
+ /* Continue HCI connection establishment */
+ btm_establish_continue (p_acl_cb);
}
-#endif /* BTM_PWR_MGR_INCLUDED == FALSE */
-
/*******************************************************************************
**
-** Function BTM_SetPacketTypes
+** Function btm_establish_continue
**
-** Description This function is set the packet types used for a specific
-** ACL connection,
+** Description This function is called when the command complete message
+** is received from the HCI for the read local link policy request.
**
-** Returns status of the operation
+** Returns void
**
*******************************************************************************/
-tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types)
+void btm_establish_continue (tACL_CONN *p_acl_cb)
{
- tACL_CONN *p;
- BTM_TRACE_DEBUG ("BTM_SetPacketTypes");
+ tBTM_BL_EVENT_DATA evt_data;
+ BTM_TRACE_DEBUG ("btm_establish_continue");
+#if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
+#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
+ if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
+#endif
+ {
+ /* For now there are a some devices that do not like sending */
+ /* commands events and data at the same time. */
+ /* Set the packet types to the default allowed by the device */
+ btm_set_packet_types (p_acl_cb, btm_cb.btm_acl_pkt_types_supported);
- if ((p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR)) != NULL)
- return(btm_set_packet_types (p, pkt_types));
+ if (btm_cb.btm_def_link_policy)
+ BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
+ }
+#endif
+ p_acl_cb->link_up_issued = TRUE;
- /* If here, no BD Addr found */
- return(BTM_UNKNOWN_ADDR);
+ /* If anyone cares, tell him database changed */
+ if (btm_cb.p_bl_changed_cb)
+ {
+ evt_data.event = BTM_BL_CONN_EVT;
+ evt_data.conn.p_bda = p_acl_cb->remote_addr;
+ evt_data.conn.p_bdn = p_acl_cb->remote_name;
+ evt_data.conn.p_dc = p_acl_cb->remote_dc;
+ evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0];
+#if BLE_INCLUDED == TRUE
+ evt_data.conn.handle = p_acl_cb->hci_handle;
+ evt_data.conn.transport = p_acl_cb->transport;
+#endif
+
+ (*btm_cb.p_bl_changed_cb)(&evt_data);
+ }
+ btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT);
}
/*******************************************************************************
**
-** Function BTM_ReadPacketTypes
+** Function BTM_SetDefaultLinkSuperTout
**
-** Description This function is set the packet types used for a specific
-** ACL connection,
+** Description Set the default value for HCI "Write Link Supervision Timeout"
+** command to use when an ACL link is created.
**
-** Returns packet types supported for the connection, or 0 if no BD address
+** Returns void
**
*******************************************************************************/
-UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda)
+void BTM_SetDefaultLinkSuperTout (UINT16 timeout)
{
- tACL_CONN *p;
-
- BTM_TRACE_DEBUG ("BTM_ReadPacketTypes");
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- if (p != (tACL_CONN *)NULL)
- {
- return(p->pkt_types_mask);
- }
-
- /* If here, no BD Addr found */
- return(0);
+ BTM_TRACE_DEBUG ("BTM_SetDefaultLinkSuperTout");
+ btm_cb.btm_def_link_super_tout = timeout;
}
-
/*******************************************************************************
**
-** Function BTM_ReadAclMode
-**
-** Description This returns the current mode for a specific
-** ACL connection.
-**
-** Input Param remote_bda - device address of desired ACL connection
+** Function BTM_GetLinkSuperTout
**
-** Output Param p_mode - address where the current mode is copied into.
-** BTM_ACL_MODE_NORMAL
-** BTM_ACL_MODE_HOLD
-** BTM_ACL_MODE_SNIFF
-** BTM_ACL_MODE_PARK
-** (valid only if return code is BTM_SUCCESS)
+** Description Read the link supervision timeout value of the connection
**
-** Returns BTM_SUCCESS if successful,
-** BTM_UNKNOWN_ADDR if bd addr is not active or bad
+** Returns status of the operation
**
*******************************************************************************/
-#if BTM_PWR_MGR_INCLUDED == FALSE
-tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode)
+tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda, UINT16 *p_timeout)
{
- tACL_CONN *p;
-
- BTM_TRACE_API ("BTM_ReadAclMode: RemBdAddr: %02x%02x%02x%02x%02x%02x",
- remote_bda[0], remote_bda[1], remote_bda[2],
- remote_bda[3], remote_bda[4], remote_bda[5]);
+ tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
+ BTM_TRACE_DEBUG ("BTM_GetLinkSuperTout");
if (p != (tACL_CONN *)NULL)
{
- *p_mode = p->mode;
+ *p_timeout = p->link_super_tout;
return(BTM_SUCCESS);
}
-
/* If here, no BD Addr found */
return(BTM_UNKNOWN_ADDR);
}
-#endif /* BTM_PWR_MGR_INCLUDED == FALSE */
+
/*******************************************************************************
**
-** Function BTM_ReadClockOffset
-**
-** Description This returns the clock offset for a specific
-** ACL connection.
+** Function BTM_SetLinkSuperTout
**
-** Input Param remote_bda - device address of desired ACL connection
+** Description Create and send HCI "Write Link Supervision Timeout" command
**
-** Returns clock-offset or 0 if unknown
+** Returns status of the operation
**
*******************************************************************************/
-UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda)
+tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda, UINT16 timeout)
{
- tACL_CONN *p;
+ tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
- BTM_TRACE_API ("BTM_ReadClockOffset: RemBdAddr: %02x%02x%02x%02x%02x%02x",
- remote_bda[0], remote_bda[1], remote_bda[2],
- remote_bda[3], remote_bda[4], remote_bda[5]);
+ BTM_TRACE_DEBUG ("BTM_SetLinkSuperTout");
+ if (p != (tACL_CONN *)NULL)
+ {
+ p->link_super_tout = timeout;
+
+ /* Only send if current role is Master; 2.0 spec requires this */
+ if (p->link_role == BTM_ROLE_MASTER)
+ {
+ if (!btsnd_hcic_write_link_super_tout (LOCAL_BR_EDR_CONTROLLER_ID,
+ p->hci_handle, timeout))
+ return(BTM_NO_RESOURCES);
- if ( (p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR)) != NULL)
- return(p->clock_offset);
+ return(BTM_CMD_STARTED);
+ }
+ else
+ return(BTM_SUCCESS);
+ }
/* If here, no BD Addr found */
- return(0);
+ return(BTM_UNKNOWN_ADDR);
}
/*******************************************************************************
*******************************************************************************/
UINT16 BTM_GetNumAclLinks (void)
{
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
- return(UINT16)btm_cb.num_acl;
-#else
- tACL_CONN *p = &btm_cb.acl_db[0];
- UINT16 xx, yy;
- BTM_TRACE_DEBUG ("BTM_GetNumAclLinks");
- for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
- {
- if (p->in_use)
- yy++;
- }
-
- return(yy);
-#endif
-}
-
-/*******************************************************************************
-**
-** Function BTM_GetNumLeLinks
-**
-** Description This function is called to count the number of
-** LE ACL links that are active.
-**
-** Returns UINT16 Number of active LE links
-**
-*******************************************************************************/
-UINT16 BTM_GetNumLeLinks (void)
-{
- UINT16 yy = 0;
+ uint16_t num_acl = 0;
-#if BLE_INCLUDED == TRUE
- tACL_CONN *p = &btm_cb.acl_db[0];
- UINT16 xx;
- BTM_TRACE_DEBUG ("BTM_GetNumLeLinks");
- for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++)
+ for (uint16_t i = 0; i < MAX_L2CAP_LINKS; ++i)
{
- if ((p->in_use) &&(p->transport == BT_TRANSPORT_LE))
- yy++;
+ if (btm_cb.acl_db[i].in_use)
+ ++num_acl;
}
-#endif
- return(yy);
+ return num_acl;
}
/*******************************************************************************
return(0xFFFF);
}
-#if BTM_PWR_MGR_INCLUDED == FALSE
-/*******************************************************************************
-**
-** Function btm_process_mode_change
-**
-** Description This function is called when an HCI mode change event occurs.
-**
-** Input Parms hci_status - status of the event (HCI_SUCCESS if no errors)
-** hci_handle - connection handle associated with the change
-** mode - HCI_MODE_ACTIVE, HCI_MODE_HOLD, HCI_MODE_SNIFF, or HCI_MODE_PARK
-** interval - number of baseband slots (meaning depends on mode)
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_process_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, UINT16 interval)
-{
- tACL_CONN *p;
- UINT8 xx;
- BTM_TRACE_DEBUG ("btm_process_mode_change");
- if (hci_status != HCI_SUCCESS)
- {
- BTM_TRACE_WARNING ("BTM: HCI Mode Change Error Status: 0x%02x", hci_status);
- }
-
- /* Look up the connection by handle and set the current mode */
- xx = btm_handle_to_acl_index(hci_handle);
-
- /* don't assume that we can never get a bad hci_handle */
- if (xx >= MAX_L2CAP_LINKS)
- return;
-
- p = &btm_cb.acl_db[xx];
-
- /* If status is not success mode does not mean anything */
- if (hci_status == HCI_SUCCESS)
- p->mode = mode;
-
- /* If mode change was because of an active role switch or change link key */
- btm_cont_rswitch_or_chglinkkey(p, btm_find_dev(p->remote_addr), hci_status);
-}
-#endif /* BTM_PWR_MGR_INCLUDED == FALSE */
-
/*******************************************************************************
**
** Function btm_process_clk_off_comp_evt
tACL_CONN *p = btm_bda_to_acl(p_bda, BT_TRANSPORT_BR_EDR);
tBTM_ROLE_SWITCH_CMPL *p_data = &btm_cb.devcb.switch_role_ref_data;
tBTM_SEC_DEV_REC *p_dev_rec;
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_ROLE_CHG_DATA evt;
-#endif
BTM_TRACE_DEBUG ("btm_acl_role_changed");
/* Ignore any stray events */
/* Update cached value */
p->link_role = new_role;
- btm_save_remote_device_role(p_bda, new_role);
+
/* Reload LSTO: link supervision timeout is reset in the LM after a role switch */
if (new_role == BTM_ROLE_MASTER)
{
/* if idle, we did not change encryption */
if (p->switch_role_state == BTM_ACL_SWKEY_STATE_SWITCHING)
{
- /* Make sure there's not also a change link key going on before re-enabling */
- if (p->change_key_state != BTM_ACL_SWKEY_STATE_SWITCHING)
- {
- if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE))
- {
- p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON;
- p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
- return;
- }
- }
- else /* Set the state and wait for change link key */
+ if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE))
{
+ p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON;
p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
return;
}
/* if role switch complete is needed, report it now */
btm_acl_report_role_change(hci_status, bd_addr);
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
/* if role change event is registered, report it now */
if (btm_cb.p_bl_changed_cb && (btm_cb.bl_evt_mask & BTM_BL_ROLE_CHG_MASK))
{
BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
p_data->role, p_data->hci_status, p->switch_role_state);
-#endif
#if BTM_DISC_DURING_RS == TRUE
/* If a disconnect is pending, issue it now that role switch has completed */
}
-#if (RFCOMM_INCLUDED==TRUE)
/*******************************************************************************
**
** Function BTM_AllocateSCN
BOOLEAN BTM_TryAllocateSCN(UINT8 scn)
{
- UINT8 x;
-
/* Make sure we don't exceed max port range.
* Stack reserves scn 1 for HFP, HSP we still do the correct way.
*/
return(FALSE); /* Illegal SCN passed in */
}
-#else
-
-/* Make dummy functions for the RPC to link against */
-UINT8 BTM_AllocateSCN(void)
-{
- return(0);
-}
-
-BOOLEAN BTM_FreeSCN(UINT8 scn)
-{
- return(FALSE);
-}
-
-#endif
-
-
-/*******************************************************************************
-**
-** Function btm_acl_timeout
-**
-** Description This function is called when a timer list entry expires.
-**
-** Returns void
-**
-*******************************************************************************/
-void btm_acl_timeout (TIMER_LIST_ENT *p_tle)
-{
- UINT32 timer_type = p_tle->param;
-
- BTM_TRACE_DEBUG ("btm_acl_timeout");
- if (timer_type == TT_DEV_RLNKP)
- {
- tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb;
- tBTM_LNK_POLICY_RESULTS lnkpol;
-
- lnkpol.status = BTM_ERR_PROCESSING;
- lnkpol.settings = 0;
-
- btm_cb.devcb.p_rlinkp_cmpl_cb = NULL;
-
- if (p_cb)
- (*p_cb)(&lnkpol);
- }
-}
-
/*******************************************************************************
**
** Function btm_set_packet_types
btm_cb.btm_acl_pkt_types_supported);
/* OR in any exception packet types if at least 2.0 version of spec */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- temp_pkt_types |= ((pkt_types & BTM_ACL_EXCEPTION_PKTS_MASK) |
- (btm_cb.btm_acl_pkt_types_supported & BTM_ACL_EXCEPTION_PKTS_MASK));
- }
- else
- {
- temp_pkt_types &= (~BTM_ACL_EXCEPTION_PKTS_MASK);
- }
+ temp_pkt_types |= ((pkt_types & BTM_ACL_EXCEPTION_PKTS_MASK) |
+ (btm_cb.btm_acl_pkt_types_supported & BTM_ACL_EXCEPTION_PKTS_MASK));
/* Exclude packet types not supported by the peer */
btm_acl_chk_peer_pkt_type_support (p, &temp_pkt_types);
else
{
/* Special case for when info for the local device is requested */
- if (memcmp (btm_cb.devcb.local_addr, addr, BD_ADDR_LEN) == 0)
+ if (memcmp (controller_get_interface()->get_address(), addr, BD_ADDR_LEN) == 0)
{
pkt_types = btm_cb.btm_acl_pkt_types_supported;
}
** Returns BTM_SUCCESS if successfully registered, otherwise error
**
*******************************************************************************/
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
tBTM_BL_EVENT_MASK evt_mask)
{
return(BTM_SUCCESS);
}
-#else
-/*******************************************************************************
-**
-** Function BTM_AclRegisterForChanges
-**
-** Returns This function is called to register a callback for when the
-** ACL database changes, i.e. new entry or entry deleted.
-**
-*******************************************************************************/
-tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb)
-{
- BTM_TRACE_DEBUG ("BTM_AclRegisterForChanges");
- if (!p_cb)
- btm_cb.p_acl_changed_cb = NULL;
- else if (btm_cb.p_acl_changed_cb)
- return(BTM_BUSY);
- else
- btm_cb.p_acl_changed_cb = p_cb;
-
- return(BTM_SUCCESS);
-}
-#endif
/*******************************************************************************
**
/*******************************************************************************
**
-** Function btm_cont_rswitch_or_chglinkkey
+** Function btm_cont_rswitch
**
** Description This function is called to continue processing an active
-** role switch or change of link key procedure. It first
-** disables encryption if enabled and EPR is not supported
+** role switch. It first disables encryption if enabled and
+** EPR is not supported
**
** Returns void
**
*******************************************************************************/
-void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec,
+void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec,
UINT8 hci_status)
{
BOOLEAN sw_ok = TRUE;
- BOOLEAN chlk_ok = TRUE;
- BTM_TRACE_DEBUG ("btm_cont_rswitch_or_chglinkkey ");
+ BTM_TRACE_DEBUG ("btm_cont_rswitch");
/* Check to see if encryption needs to be turned off if pending
change of link key or role switch */
- if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE ||
- p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
+ if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
{
/* Must turn off Encryption first if necessary */
/* Some devices do not support switch or change of link key while encryption is on */
p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF;
if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF;
-
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
- p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF;
}
else
{
/* Error occurred; set states back to Idle */
if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
sw_ok = FALSE;
-
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
- chlk_ok = FALSE;
}
}
else /* Encryption not used or EPR supported, continue with switch
#endif
sw_ok = btsnd_hcic_switch_role (p->remote_addr, (UINT8)!p->link_role);
}
-
- if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE)
- {
- p->switch_role_state = BTM_ACL_SWKEY_STATE_IN_PROGRESS;
- chlk_ok = btsnd_hcic_change_link_key (p->hci_handle);
- }
}
if (!sw_ok)
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
btm_acl_report_role_change(hci_status, p->remote_addr);
}
-
- if (!chlk_ok)
- {
- p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE;
- if (btm_cb.devcb.p_chg_link_key_cb)
- {
- btm_cb.devcb.chg_link_key_ref_data.hci_status = hci_status;
- (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data);
- btm_cb.devcb.p_chg_link_key_cb = NULL;
- }
- }
}
}
/*******************************************************************************
**
-** Function btm_acl_set_discing
-**
-** Description set discing to the given value
-**
-*******************************************************************************/
-void btm_acl_set_discing (BOOLEAN discing)
-{
- BTM_TRACE_DEBUG ("btm_acl_set_discing");
- btm_cb.discing = discing;
-}
-
-/*******************************************************************************
-**
** Function btm_acl_paging
**
** Description send a paging command or queue it in btm_cb
** Description Send connection collision event to upper layer if registered
**
** Returns TRUE if sent out to upper layer,
-** FALSE if BTM_BUSY_LEVEL_CHANGE_INCLUDED == FALSE, or no one
-** needs the notification.
-**
-** Note: Function only used if BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE
+** FALSE if no one needs the notification.
**
*******************************************************************************/
BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda)
{
-#if (BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
tBTM_BL_EVENT_DATA evt_data;
/* Report possible collision to the upper layer. */
}
else
return FALSE;
-#else
- return FALSE;
-#endif
}
if (!HCI_5_SLOT_PACKETS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
*p_pkt_type &= ~(BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5);
- /* If HCI version > 2.0, then also check EDR packet types */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- /* 2 and 3 MPS support? */
- if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- /* Not supported. Add 'not_supported' mask for all 2MPS packet types */
- *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
- BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
+ /* 2 and 3 MPS support? */
+ if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ /* Not supported. Add 'not_supported' mask for all 2MPS packet types */
+ *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
+ BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
- if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- /* Not supported. Add 'not_supported' mask for all 3MPS packet types */
- *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
- BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
+ if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ /* Not supported. Add 'not_supported' mask for all 3MPS packet types */
+ *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
+ BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
- /* EDR 3 and 5 slot support? */
- if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])
- || HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- {
- if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- /* Not supported. Add 'not_supported' mask for all 3-slot EDR packet types */
- *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
+ /* EDR 3 and 5 slot support? */
+ if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])
+ || HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ {
+ if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ /* Not supported. Add 'not_supported' mask for all 3-slot EDR packet types */
+ *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
- if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
- /* Not supported. Add 'not_supported' mask for all 5-slot EDR packet types */
- *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
- }
+ if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
+ /* Not supported. Add 'not_supported' mask for all 5-slot EDR packet types */
+ *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
}
}