2016-11-02 05:42:26 -04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002-2012 Broadcom Corporation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* This AVDTP adaption layer module interfaces to L2CAP
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include <string.h>
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "stack/bt_types.h"
|
|
|
|
#include "common/bt_target.h"
|
|
|
|
#include "common/bt_defs.h"
|
|
|
|
#include "stack/avdt_api.h"
|
|
|
|
#include "stack/avdtc_api.h"
|
2016-11-02 05:42:26 -04:00
|
|
|
#include "avdt_int.h"
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "stack/l2c_api.h"
|
|
|
|
#include "stack/l2cdefs.h"
|
|
|
|
#include "stack/btm_api.h"
|
2016-11-02 05:42:26 -04:00
|
|
|
#include "btm_int.h"
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "osi/allocator.h"
|
2016-11-02 05:42:26 -04:00
|
|
|
|
2017-03-17 03:08:47 -04:00
|
|
|
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
|
2016-11-02 05:42:26 -04:00
|
|
|
|
|
|
|
/* callback function declarations */
|
|
|
|
void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id);
|
|
|
|
void avdt_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result);
|
|
|
|
void avdt_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
|
|
|
|
void avdt_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg);
|
|
|
|
void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed);
|
|
|
|
void avdt_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result);
|
|
|
|
void avdt_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested);
|
|
|
|
void avdt_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf);
|
|
|
|
|
|
|
|
/* L2CAP callback function structure */
|
|
|
|
const tL2CAP_APPL_INFO avdt_l2c_appl = {
|
|
|
|
avdt_l2c_connect_ind_cback,
|
|
|
|
avdt_l2c_connect_cfm_cback,
|
|
|
|
NULL,
|
|
|
|
avdt_l2c_config_ind_cback,
|
|
|
|
avdt_l2c_config_cfm_cback,
|
|
|
|
avdt_l2c_disconnect_ind_cback,
|
|
|
|
avdt_l2c_disconnect_cfm_cback,
|
|
|
|
NULL,
|
|
|
|
avdt_l2c_data_ind_cback,
|
|
|
|
avdt_l2c_congestion_ind_cback,
|
|
|
|
NULL /* tL2CA_TX_COMPLETE_CB */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_sec_check_complete_term
|
|
|
|
**
|
|
|
|
** Description The function called when Security Manager finishes
|
|
|
|
** verification of the service side connection
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
static void avdt_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transport,
|
2017-03-17 10:46:49 -04:00
|
|
|
void *p_ref_data, UINT8 res)
|
2016-11-02 05:42:26 -04:00
|
|
|
{
|
|
|
|
tAVDT_CCB *p_ccb = NULL;
|
|
|
|
tL2CAP_CFG_INFO cfg;
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
UNUSED(p_ref_data);
|
|
|
|
|
2016-11-15 22:05:55 -05:00
|
|
|
AVDT_TRACE_DEBUG("avdt_sec_check_complete_term res: %d\n", res);
|
2017-03-17 10:46:49 -04:00
|
|
|
if (!bd_addr) {
|
2016-11-02 05:42:26 -04:00
|
|
|
AVDT_TRACE_WARNING("avdt_sec_check_complete_term: NULL BD_ADDR");
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
p_ccb = avdt_ccb_by_bd(bd_addr);
|
|
|
|
|
|
|
|
p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_ACP);
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl == NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
return;
|
2017-03-17 10:46:49 -04:00
|
|
|
}
|
2016-11-02 05:42:26 -04:00
|
|
|
|
2017-03-17 10:46:49 -04:00
|
|
|
if (res == BTM_SUCCESS) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* Send response to the L2CAP layer. */
|
|
|
|
L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_OK, L2CAP_CONN_OK);
|
|
|
|
|
|
|
|
/* store idx in LCID table, store LCID in routing table */
|
|
|
|
avdt_cb.ad.lcid_tbl[p_tbl->lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl);
|
|
|
|
avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = p_tbl->lcid;
|
|
|
|
|
|
|
|
/* transition to configuration state */
|
|
|
|
p_tbl->state = AVDT_AD_ST_CFG;
|
|
|
|
|
|
|
|
/* Send L2CAP config req */
|
|
|
|
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
|
|
|
|
cfg.mtu_present = TRUE;
|
|
|
|
cfg.mtu = p_tbl->my_mtu;
|
|
|
|
cfg.flush_to_present = TRUE;
|
|
|
|
cfg.flush_to = p_tbl->my_flush_to;
|
|
|
|
L2CA_ConfigReq(p_tbl->lcid, &cfg);
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
L2CA_ConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_SECURITY_BLOCK, L2CAP_CONN_OK);
|
|
|
|
avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_sec_check_complete_orig
|
|
|
|
**
|
|
|
|
** Description The function called when Security Manager finishes
|
|
|
|
** verification of the service side connection
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
static void avdt_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
|
2017-03-17 10:46:49 -04:00
|
|
|
void *p_ref_data, UINT8 res)
|
2016-11-02 05:42:26 -04:00
|
|
|
{
|
|
|
|
tAVDT_CCB *p_ccb = NULL;
|
|
|
|
tL2CAP_CFG_INFO cfg;
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
UNUSED(p_ref_data);
|
|
|
|
|
2016-11-15 22:05:55 -05:00
|
|
|
AVDT_TRACE_DEBUG("avdt_sec_check_complete_orig res: %d\n", res);
|
2017-03-17 10:46:49 -04:00
|
|
|
if (bd_addr) {
|
2016-11-02 05:42:26 -04:00
|
|
|
p_ccb = avdt_ccb_by_bd(bd_addr);
|
2017-03-17 10:46:49 -04:00
|
|
|
}
|
2016-11-02 05:42:26 -04:00
|
|
|
p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_SEC_INT);
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl == NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
return;
|
2017-03-17 10:46:49 -04:00
|
|
|
}
|
2016-11-02 05:42:26 -04:00
|
|
|
|
2017-03-17 10:46:49 -04:00
|
|
|
if ( res == BTM_SUCCESS ) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* set channel state */
|
|
|
|
p_tbl->state = AVDT_AD_ST_CFG;
|
|
|
|
|
|
|
|
/* Send L2CAP config req */
|
|
|
|
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
|
|
|
|
cfg.mtu_present = TRUE;
|
|
|
|
cfg.mtu = p_tbl->my_mtu;
|
|
|
|
cfg.flush_to_present = TRUE;
|
|
|
|
cfg.flush_to = p_tbl->my_flush_to;
|
|
|
|
L2CA_ConfigReq(p_tbl->lcid, &cfg);
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
L2CA_DisconnectReq (p_tbl->lcid);
|
|
|
|
avdt_ad_tc_close_ind(p_tbl, L2CAP_CONN_SECURITY_BLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_connect_ind_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP connect indication callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_connect_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
|
|
|
|
{
|
|
|
|
tAVDT_CCB *p_ccb;
|
|
|
|
tAVDT_TC_TBL *p_tbl = NULL;
|
|
|
|
UINT16 result;
|
|
|
|
tL2CAP_CFG_INFO cfg;
|
|
|
|
tBTM_STATUS rc;
|
|
|
|
UNUSED(psm);
|
|
|
|
|
|
|
|
/* do we already have a control channel for this peer? */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* no, allocate ccb */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_ccb = avdt_ccb_alloc(bd_addr)) == NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* no ccb available, reject L2CAP connection */
|
|
|
|
result = L2CAP_CONN_NO_RESOURCES;
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* allocate and set up entry; first channel is always signaling */
|
|
|
|
p_tbl = avdt_ad_tc_tbl_alloc(p_ccb);
|
|
|
|
p_tbl->my_mtu = avdt_cb.rcb.ctrl_mtu;
|
|
|
|
p_tbl->my_flush_to = L2CAP_DEFAULT_FLUSH_TO;
|
|
|
|
p_tbl->tcid = AVDT_CHAN_SIG;
|
|
|
|
p_tbl->lcid = lcid;
|
|
|
|
p_tbl->id = id;
|
|
|
|
p_tbl->state = AVDT_AD_ST_SEC_ACP;
|
|
|
|
p_tbl->cfg_flags = AVDT_L2C_CFG_CONN_ACP;
|
|
|
|
|
|
|
|
/* Check the security */
|
|
|
|
rc = btm_sec_mx_access_request (bd_addr, AVDT_PSM,
|
2017-03-17 10:46:49 -04:00
|
|
|
FALSE, BTM_SEC_PROTO_AVDT,
|
|
|
|
AVDT_CHAN_SIG,
|
|
|
|
&avdt_sec_check_complete_term, NULL);
|
|
|
|
if (rc == BTM_CMD_STARTED) {
|
2016-11-02 05:42:26 -04:00
|
|
|
L2CA_ConnectRsp (p_ccb->peer_addr, p_tbl->id, lcid, L2CAP_CONN_PENDING, L2CAP_CONN_OK);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* deal with simultaneous control channel connect case */
|
2017-03-17 10:46:49 -04:00
|
|
|
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_SIG, p_ccb, AVDT_AD_ST_CONN)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* reject their connection */
|
|
|
|
result = L2CAP_CONN_NO_RESOURCES;
|
|
|
|
}
|
|
|
|
/* this must be a traffic channel; are we accepting a traffic channel
|
|
|
|
** for this ccb?
|
|
|
|
*/
|
2017-03-17 10:46:49 -04:00
|
|
|
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_MEDIA, p_ccb, AVDT_AD_ST_ACP)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* yes; proceed with connection */
|
|
|
|
result = L2CAP_CONN_OK;
|
|
|
|
}
|
|
|
|
#if AVDT_REPORTING == TRUE
|
|
|
|
/* this must be a reporting channel; are we accepting a reporting channel
|
|
|
|
** for this ccb?
|
|
|
|
*/
|
2017-03-17 10:46:49 -04:00
|
|
|
else if ((p_tbl = avdt_ad_tc_tbl_by_st(AVDT_CHAN_REPORT, p_ccb, AVDT_AD_ST_ACP)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* yes; proceed with connection */
|
|
|
|
result = L2CAP_CONN_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* else we're not listening for traffic channel; reject */
|
2017-03-17 10:46:49 -04:00
|
|
|
else {
|
2016-11-02 05:42:26 -04:00
|
|
|
result = L2CAP_CONN_NO_PSM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send L2CAP connect rsp */
|
|
|
|
L2CA_ConnectRsp(bd_addr, id, lcid, result, 0);
|
|
|
|
|
|
|
|
/* if result ok, proceed with connection */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (result == L2CAP_CONN_OK) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* store idx in LCID table, store LCID in routing table */
|
|
|
|
avdt_cb.ad.lcid_tbl[lcid - L2CAP_BASE_APPL_CID] = avdt_ad_tc_tbl_to_idx(p_tbl);
|
|
|
|
avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][p_tbl->tcid].lcid = lcid;
|
|
|
|
|
|
|
|
/* transition to configuration state */
|
|
|
|
p_tbl->state = AVDT_AD_ST_CFG;
|
|
|
|
|
|
|
|
/* Send L2CAP config req */
|
|
|
|
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
|
|
|
|
cfg.mtu_present = TRUE;
|
|
|
|
cfg.mtu = p_tbl->my_mtu;
|
|
|
|
cfg.flush_to_present = TRUE;
|
|
|
|
cfg.flush_to = p_tbl->my_flush_to;
|
|
|
|
L2CA_ConfigReq(lcid, &cfg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_connect_cfm_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP connect confirm callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_connect_cfm_cback(UINT16 lcid, UINT16 result)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
tL2CAP_CFG_INFO cfg;
|
|
|
|
tAVDT_CCB *p_ccb;
|
|
|
|
|
2016-11-15 22:05:55 -05:00
|
|
|
AVDT_TRACE_DEBUG("avdt_l2c_connect_cfm_cback lcid: %d, result: %d\n",
|
2017-03-17 10:46:49 -04:00
|
|
|
lcid, result);
|
2016-11-02 05:42:26 -04:00
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* if in correct state */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl->state == AVDT_AD_ST_CONN) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* if result successful */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (result == L2CAP_CONN_OK) {
|
|
|
|
if (p_tbl->tcid != AVDT_CHAN_SIG) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* set channel state */
|
|
|
|
p_tbl->state = AVDT_AD_ST_CFG;
|
|
|
|
|
|
|
|
/* Send L2CAP config req */
|
|
|
|
memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
|
|
|
|
cfg.mtu_present = TRUE;
|
|
|
|
cfg.mtu = p_tbl->my_mtu;
|
|
|
|
cfg.flush_to_present = TRUE;
|
|
|
|
cfg.flush_to = p_tbl->my_flush_to;
|
|
|
|
L2CA_ConfigReq(lcid, &cfg);
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_ccb == NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
result = L2CAP_CONN_NO_RESOURCES;
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* set channel state */
|
|
|
|
p_tbl->state = AVDT_AD_ST_SEC_INT;
|
|
|
|
p_tbl->lcid = lcid;
|
|
|
|
p_tbl->cfg_flags = AVDT_L2C_CFG_CONN_INT;
|
|
|
|
|
|
|
|
/* Check the security */
|
|
|
|
btm_sec_mx_access_request (p_ccb->peer_addr, AVDT_PSM,
|
2017-03-17 10:46:49 -04:00
|
|
|
TRUE, BTM_SEC_PROTO_AVDT,
|
|
|
|
AVDT_CHAN_SIG,
|
|
|
|
&avdt_sec_check_complete_orig, NULL);
|
2016-11-02 05:42:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* failure; notify adaption that channel closed */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (result != L2CAP_CONN_OK) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_close_ind(p_tbl, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_config_cfm_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP config confirm callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
|
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
p_tbl->lcid = lcid;
|
|
|
|
|
|
|
|
/* if in correct state */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl->state == AVDT_AD_ST_CFG) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* if result successful */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_cfg->result == L2CAP_CONN_OK) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* update cfg_flags */
|
|
|
|
p_tbl->cfg_flags |= AVDT_L2C_CFG_CFM_DONE;
|
|
|
|
|
|
|
|
/* if configuration complete */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_open_ind(p_tbl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* else failure */
|
2017-03-17 10:46:49 -04:00
|
|
|
else {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* Send L2CAP disconnect req */
|
|
|
|
L2CA_DisconnectReq(lcid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_config_ind_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP config indication callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_config_ind_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
|
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* store the mtu in tbl */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_cfg->mtu_present) {
|
2016-11-02 05:42:26 -04:00
|
|
|
p_tbl->peer_mtu = p_cfg->mtu;
|
2017-03-17 10:46:49 -04:00
|
|
|
} else {
|
2016-11-02 05:42:26 -04:00
|
|
|
p_tbl->peer_mtu = L2CAP_DEFAULT_MTU;
|
|
|
|
}
|
2017-03-17 10:46:49 -04:00
|
|
|
AVDT_TRACE_DEBUG("peer_mtu: %d, lcid: x%x\n", p_tbl->peer_mtu, lcid);
|
2016-11-02 05:42:26 -04:00
|
|
|
|
|
|
|
/* send L2CAP configure response */
|
|
|
|
memset(p_cfg, 0, sizeof(tL2CAP_CFG_INFO));
|
|
|
|
p_cfg->result = L2CAP_CFG_OK;
|
|
|
|
L2CA_ConfigRsp(lcid, p_cfg);
|
|
|
|
|
|
|
|
/* if first config ind */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl->cfg_flags & AVDT_L2C_CFG_IND_DONE) == 0) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* update cfg_flags */
|
|
|
|
p_tbl->cfg_flags |= AVDT_L2C_CFG_IND_DONE;
|
|
|
|
|
|
|
|
/* if configuration complete */
|
2017-03-17 10:46:49 -04:00
|
|
|
if (p_tbl->cfg_flags & AVDT_L2C_CFG_CFM_DONE) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_open_ind(p_tbl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_disconnect_ind_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP disconnect indication callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
2017-02-23 01:30:08 -05:00
|
|
|
UINT16 disc_rsn = AVDT_DISC_RSN_NORMAL;
|
2016-11-15 22:05:55 -05:00
|
|
|
AVDT_TRACE_DEBUG("avdt_l2c_disconnect_ind_cback lcid: %d, ack_needed: %d\n",
|
2017-03-17 10:46:49 -04:00
|
|
|
lcid, ack_needed);
|
2016-11-02 05:42:26 -04:00
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
|
|
|
if (ack_needed) {
|
2016-11-02 05:42:26 -04:00
|
|
|
/* send L2CAP disconnect response */
|
|
|
|
L2CA_DisconnectRsp(lcid);
|
2017-02-23 01:30:08 -05:00
|
|
|
} else {
|
|
|
|
disc_rsn = AVDT_DISC_RSN_ABNORMAL;
|
2016-11-02 05:42:26 -04:00
|
|
|
}
|
|
|
|
|
2017-02-23 01:30:08 -05:00
|
|
|
avdt_ad_tc_close_ind(p_tbl, disc_rsn);
|
2016-11-02 05:42:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_disconnect_cfm_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP disconnect confirm callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_disconnect_cfm_cback(UINT16 lcid, UINT16 result)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
|
2016-11-15 22:05:55 -05:00
|
|
|
AVDT_TRACE_DEBUG("avdt_l2c_disconnect_cfm_cback lcid: %d, result: %d\n",
|
2017-03-17 10:46:49 -04:00
|
|
|
lcid, result);
|
2016-11-02 05:42:26 -04:00
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_close_ind(p_tbl, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_congestion_ind_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP congestion indication callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_congestion_ind_cback(UINT16 lcid, BOOLEAN is_congested)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
|
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_cong_ind(p_tbl, is_congested);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
**
|
|
|
|
** Function avdt_l2c_data_ind_cback
|
|
|
|
**
|
|
|
|
** Description This is the L2CAP data indication callback function.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** Returns void
|
|
|
|
**
|
|
|
|
*******************************************************************************/
|
|
|
|
void avdt_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
|
|
|
|
{
|
|
|
|
tAVDT_TC_TBL *p_tbl;
|
|
|
|
|
|
|
|
/* look up info for this channel */
|
2017-03-17 10:46:49 -04:00
|
|
|
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
|
2016-11-02 05:42:26 -04:00
|
|
|
avdt_ad_tc_data_ind(p_tbl, p_buf);
|
2017-03-17 10:46:49 -04:00
|
|
|
} else { /* prevent buffer leak */
|
2017-08-17 09:13:45 -04:00
|
|
|
osi_free(p_buf);
|
2017-03-17 10:46:49 -04:00
|
|
|
}
|
2016-11-02 05:42:26 -04:00
|
|
|
}
|
|
|
|
|
2017-03-17 03:08:47 -04:00
|
|
|
#endif /* #if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE) */
|