component/bt: Added the new feature of the l2cap layer from the bluedroid new version 7.1.1

This commit is contained in:
Yulong
2017-08-08 03:32:59 -04:00
parent aad24cb6c7
commit 371c55138e
11 changed files with 1160 additions and 13 deletions
@@ -416,6 +416,15 @@ void btm_sco_chk_pend_rolechange (UINT16 hci_handle);
** Define structure for Security Service Record.
** A record exists for each service registered with the Security Manager
*/
#define BTM_SEC_OUT_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_AUTHORIZE)
#define BTM_SEC_IN_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_AUTHORIZE)
#define BTM_SEC_OUT_LEVEL4_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | \
BTM_SEC_OUT_MITM | BTM_SEC_MODE4_LEVEL4)
#define BTM_SEC_IN_LEVEL4_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | \
BTM_SEC_IN_MITM | BTM_SEC_MODE4_LEVEL4)
typedef struct {
UINT32 mx_proto_id; /* Service runs over this multiplexer protocol */
UINT32 orig_mx_chan_id; /* Channel on the multiplexer protocol */
@@ -878,6 +887,15 @@ typedef struct{
}tBTM_CallbackFunc;
extern tBTM_CallbackFunc conn_param_update_cb;
/* security action for L2CAP COC channels */
#define BTM_SEC_OK 1
#define BTM_SEC_ENCRYPT 2 /* encrypt the link with current key */
#define BTM_SEC_ENCRYPT_NO_MITM 3 /* unauthenticated encryption or better */
#define BTM_SEC_ENCRYPT_MITM 4 /* authenticated encryption */
#define BTM_SEC_ENC_PENDING 5 /* wait for link encryption pending */
typedef UINT8 tBTM_SEC_ACTION;
/*
#ifdef __cplusplus
extern "C"
@@ -1082,6 +1100,10 @@ BOOLEAN btm_sec_is_a_bonded_dev (BD_ADDR bda);
void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec);
BOOLEAN btm_sec_is_le_capable_dev (BD_ADDR bda);
BOOLEAN btm_ble_init_pseudo_addr (tBTM_SEC_DEV_REC *p_dev_rec, BD_ADDR new_pseudo_addr);
extern BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator,
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
extern tBTM_SEC_SERV_REC *btm_sec_find_first_serv (CONNECTION_TYPE conn_type, UINT16 psm);
#endif /* BLE_INCLUDED */
tINQ_DB_ENT *btm_inq_db_new (BD_ADDR p_bda);
@@ -124,6 +124,8 @@ typedef UINT8 tL2CAP_CHNL_DATA_RATE;
*/
#define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
#define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
#define L2C_IS_VALID_LE_PSM(psm) (((psm) > 0x0000) && ((psm) < 0x0100))
/*****************************************************************************
** Type Definitions
@@ -164,6 +166,17 @@ typedef struct {
UINT16 flags; /* bit 0: 0-no continuation, 1-continuation */
} tL2CAP_CFG_INFO;
/* Define a structure to hold the configuration parameter for LE L2CAP connection
** oriented channels.
*/
typedef struct
{
UINT16 mtu;
UINT16 mps;
UINT16 credits;
} tL2CAP_LE_CFG_INFO;
/* L2CAP channel configured field bitmap */
#define L2CAP_CH_CFG_MASK_MTU 0x0001
#define L2CAP_CH_CFG_MASK_QOS 0x0002
@@ -486,6 +499,72 @@ extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
** Function L2CA_RegisterLECoc
**
** Description Other layers call this function to register for L2CAP
** Connection Oriented Channel.
**
** Returns PSM to use or zero if error. Typically, the PSM returned
** is the same as was passed in, but for an outgoing-only
** connection to a dynamic PSM, a "virtual" PSM is returned
** and should be used in the calls to L2CA_ConnectLECocReq()
** and BTM_SetSecurityLevel().
**
*******************************************************************************/
extern UINT16 L2CA_RegisterLECoc (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
/*******************************************************************************
**
** Function L2CA_DeregisterLECoc
**
** Description Other layers call this function to deregister for L2CAP
** Connection Oriented Channel.
**
** Returns void
**
*******************************************************************************/
extern void L2CA_DeregisterLECoc (UINT16 psm);
/*******************************************************************************
**
** Function L2CA_ConnectLECocReq
**
** Description Higher layers call this function to create an L2CAP LE COC.
** Note that the connection is not established at this time, but
** connection establishment gets started. The callback function
** will be invoked when connection establishes or fails.
**
** Returns the CID of the connection, or 0 if it failed to start
**
*******************************************************************************/
extern UINT16 L2CA_ConnectLECocReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p_cfg);
/*******************************************************************************
**
** Function L2CA_ConnectLECocRsp
**
** Description Higher layers call this function to accept an incoming
** L2CAP LE COC connection, for which they had gotten an connect
** indication callback.
**
** Returns TRUE for success, FALSE for failure
**
*******************************************************************************/
extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result,
UINT16 status, tL2CAP_LE_CFG_INFO *p_cfg);
/*******************************************************************************
**
** Function L2CA_GetPeerLECocConfig
**
** Description Get peers configuration for LE Connection Oriented Channel.
**
** Return value: TRUE if peer is connected
**
*******************************************************************************/
extern BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg);
/*******************************************************************************
**
@@ -41,6 +41,10 @@
#define L2CAP_CMD_BLE_UPDATE_REQ 0x12
#define L2CAP_CMD_BLE_UPDATE_RSP 0x13
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ 0x14
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES 0x15
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT 0x16
/* Define some packet and header lengths
@@ -70,6 +74,11 @@
#define L2CAP_CMD_BLE_UPD_REQ_LEN 8 /* Min and max interval, latency, tout */
#define L2CAP_CMD_BLE_UPD_RSP_LEN 2 /* Result */
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN 10 /* LE_PSM, SCID, MTU, MPS, Init Credit */
#define L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN 10 /* DCID, MTU, MPS, Init credit, Result */
#define L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN 4 /* CID, Credit */
/* Define the packet boundary flags
*/