109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/******************************************************************************
209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  Copyright (C) 1999-2012 Broadcom Corporation
409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  Licensed under the Apache License, Version 2.0 (the "License");
609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  you may not use this file except in compliance with the License.
709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  You may obtain a copy of the License at:
809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  http://www.apache.org/licenses/LICENSE-2.0
1009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
11c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul *  Unless required by applicable law or agreed to in writing, software
1209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  distributed under the License is distributed on an "AS IS" BASIS,
1309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  See the License for the specific language governing permissions and
1509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  limitations under the License.
1609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
1709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul ******************************************************************************/
1809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
19c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul/******************************************************************************
2009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
2109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *  this file contains the L2CAP API definitions
2209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul *
2309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul ******************************************************************************/
2409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#ifndef L2C_API_H
2509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2C_API_H
2609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
2709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#include "bt_target.h"
2809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#include "l2cdefs.h"
2909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#include "hcidefs.h"
3009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
3109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/*****************************************************************************
3209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**  Constants
3309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*****************************************************************************/
3409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
356e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick/* Define the minimum offset that L2CAP needs in a buffer. This is made up of
3609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul** HCI type(1), len(2), handle(2), L2CAP len(2) and CID(2) => 9
3709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*/
3809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MIN_OFFSET    13     /* plus control(2), SDU length(2) */
3909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
4009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Minimum offset for broadcast needs another two bytes for the PSM */
4109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_BCST_MIN_OFFSET       11
4209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
4309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* ping result codes */
4409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_PING_RESULT_OK        0       /* Ping reply received OK     */
4509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_PING_RESULT_NO_LINK   1       /* Link could not be setup    */
4609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_PING_RESULT_NO_RESP   2       /* Remote L2CAP did not reply */
4709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
4809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* result code for L2CA_DataWrite() */
4909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_DW_FAILED        FALSE
5009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_DW_SUCCESS       TRUE
5109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_DW_CONGESTED     2
5209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
5309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Values for priority parameter to L2CA_SetAclPriority */
5409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_PRIORITY_NORMAL       0
5509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_PRIORITY_HIGH         1
5609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
5709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Values for priority parameter to L2CA_SetTxPriority */
5809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_PRIORITY_HIGH    0
5909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_PRIORITY_MEDIUM  1
6009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_PRIORITY_LOW     2
6109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
626e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanicktypedef UINT8 tL2CAP_CHNL_PRIORITY;
6309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
6409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Values for Tx/Rx data rate parameter to L2CA_SetChnlDataRate */
6509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_DATA_RATE_HIGH       3
6609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_DATA_RATE_MEDIUM     2
6709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_DATA_RATE_LOW        1
6809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CHNL_DATA_RATE_NO_TRAFFIC 0
6909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
7009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef UINT8 tL2CAP_CHNL_DATA_RATE;
7109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
7209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Data Packet Flags  (bits 2-15 are reserved) */
7309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* layer specific 14-15 bits are used for FCR SAR */
7409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FLUSHABLE_MASK        0x0003
7509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FLUSHABLE_CH_BASED    0x0000
7609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FLUSHABLE_PKT         0x0001
7709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_NON_FLUSHABLE_PKT     0x0002
7809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
7909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
8009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* L2CA_FlushChannel num_to_flush definitions */
8109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FLUSH_CHANS_ALL       0xffff
8209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FLUSH_CHANS_GET       0x0000
8309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
8409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
8509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* special CID for Multi-AV for reporting congestion */
8609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MULTI_AV_CID          0
8709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
8809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* length of the HCI header block */
8909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) */
9009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MULTI_AV_HCI_HDR_LEN	8
9109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
9209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* length of padding for 4 bytes align */
9309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MULTI_AV_PADDING_LEN  2
9409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
9509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* length of the HCI header block with padding for FCR */
9609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) + padding(2) */
9709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING	10
9809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
9909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* length of the L2CAP header block */
10009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* HCI header(4) + L2CAP header(4) + padding(4) or control word(2) + FCS(2) */
10109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_MULTI_AV_L2C_HDR_LEN	12
10209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
10309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* definition used for L2CA_SetDesireRole */
10409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_ROLE_SLAVE            HCI_ROLE_SLAVE
10509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_ROLE_MASTER           HCI_ROLE_MASTER
10609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_ROLE_ALLOW_SWITCH     0x80    /* set this bit to allow switch at create conn */
10709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_ROLE_DISALLOW_SWITCH  0x40    /* set this bit to disallow switch at create conn */
10809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_ROLE_CHECK_SWITCH     0xC0
10909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
11009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
11109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Values for 'allowed_modes' field passed in structure tL2CAP_ERTM_INFO
11209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*/
1136e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick#define L2CAP_FCR_CHAN_OPT_BASIC    (1 << L2CAP_FCR_BASIC_MODE)
11409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_CHAN_OPT_ERTM     (1 << L2CAP_FCR_ERTM_MODE)
11509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_CHAN_OPT_STREAM   (1 << L2CAP_FCR_STREAM_MODE)
11609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
11709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
11809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
11909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Validity check for PSM.  PSM values must be odd.  Also, all PSM values must
12009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul** be assigned such that the least significant bit of the most sigificant
12109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul** octet equals zero.
1226e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick*/
12309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2C_INVALID_PSM(psm)    (((psm) & 0x0101) != 0x0001)
12409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2C_IS_VALID_PSM(psm)   (((psm) & 0x0101) == 0x0001)
12509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
12609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/*****************************************************************************
12709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**  Type Definitions
12809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*****************************************************************************/
12909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
13009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef struct
13109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul{
13209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_BASIC_MODE    0x00
13309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_ERTM_MODE     0x03
13409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_FCR_STREAM_MODE   0x04
13509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
13609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT8  mode;
13709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
13809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT8  tx_win_sz;
13909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT8  max_transmit;
14009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16 rtrans_tout;
14109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16 mon_tout;
14209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16 mps;
14309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul} tL2CAP_FCR_OPTS;
14409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
14509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Define a structure to hold the configuration parameters. Since the
1466e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick** parameters are optional, for each parameter there is a boolean to
14709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul** use to signify its presence or absence.
14809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*/
14909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef struct
15009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul{
15109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16      result;                 /* Only used in confirm messages */
15209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN     mtu_present;
15309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16      mtu;
15409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN     qos_present;
1556e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick    FLOW_SPEC   qos;
15609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN     flush_to_present;
15709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16      flush_to;
15809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN     fcr_present;
15909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    tL2CAP_FCR_OPTS fcr;
16009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN     fcs_present;            /* Optionally bypasses FCS checks */
16109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT8       fcs;                    /* '0' if desire is to bypass FCS, otherwise '1' */
16209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    BOOLEAN               ext_flow_spec_present;
16309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    tHCI_EXT_FLOW_SPEC    ext_flow_spec;
16409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul    UINT16      flags;                  /* bit 0: 0-no continuation, 1-continuation */
16509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul} tL2CAP_CFG_INFO;
16609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
16709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* L2CAP channel configured field bitmap */
16809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_MTU           0x0001
16909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_QOS           0x0002
17009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_FLUSH_TO      0x0004
17109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_FCR           0x0008
17209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_FCS           0x0010
17309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul#define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC 0x0020
1746e2ab82f5c2bc41c1dcb146c0fe9606f3bfe4eb1Ian Romanick
17509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef UINT16 tL2CAP_CH_CFG_BITS;
17609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
17709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/*********************************
17809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**  Callback Functions Prototypes
17909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**********************************/
18009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
18109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Connection indication callback prototype. Parameters are
18209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              BD Address of remote
18309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              Local CID assigned to the connection
18409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              PSM that the remote wants to connect to
18509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              Identifier that the remote sent
18609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*/
18709b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef void (tL2CA_CONNECT_IND_CB) (BD_ADDR, UINT16, UINT16, UINT8);
18809b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
18909b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
19009b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul/* Connection confirmation callback prototype. Parameters are
19109b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              Local CID
19209b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul**              Result - 0 = connected, non-zero means failure reason
19309b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul*/
19409b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paultypedef void (tL2CA_CONNECT_CFM_CB) (UINT16, UINT16);
19509b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
19609b00c5ded8e6211c9c79be600bb8c8ecad0d8fcBrian Paul
197c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul/* Connection pending callback prototype. Parameters are
198c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul**              Local CID
199c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul*/
200c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paultypedef void (tL2CA_CONNECT_PND_CB) (UINT16);
201c784d87b0f07590a2bb87307ca6a264b2ec99b31Brian Paul
202
203/* Configuration indication callback prototype. Parameters are
204**              Local CID assigned to the connection
205**              Pointer to configuration info
206*/
207typedef void (tL2CA_CONFIG_IND_CB) (UINT16, tL2CAP_CFG_INFO *);
208
209
210/* Configuration confirm callback prototype. Parameters are
211**              Local CID assigned to the connection
212**              Pointer to configuration info
213*/
214typedef void (tL2CA_CONFIG_CFM_CB) (UINT16, tL2CAP_CFG_INFO *);
215
216
217/* Disconnect indication callback prototype. Parameters are
218**              Local CID
219**              Boolean whether upper layer should ack this
220*/
221typedef void (tL2CA_DISCONNECT_IND_CB) (UINT16, BOOLEAN);
222
223
224/* Disconnect confirm callback prototype. Parameters are
225**              Local CID
226**              Result
227*/
228typedef void (tL2CA_DISCONNECT_CFM_CB) (UINT16, UINT16);
229
230
231/* QOS Violation indication callback prototype. Parameters are
232**              BD Address of violating device
233*/
234typedef void (tL2CA_QOS_VIOLATION_IND_CB) (BD_ADDR);
235
236
237/* Data received indication callback prototype. Parameters are
238**              Local CID
239**              Address of buffer
240*/
241typedef void (tL2CA_DATA_IND_CB) (UINT16, BT_HDR *);
242
243
244/* Echo response callback prototype. Note that this is not included in the
245** registration information, but is passed to L2CAP as part of the API to
246** actually send an echo request. Parameters are
247**              Result
248*/
249typedef void (tL2CA_ECHO_RSP_CB) (UINT16);
250
251
252/* Callback function prototype to pass broadcom specific echo response  */
253/* to the upper layer                                                   */
254typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
255
256
257/* Congestion status callback protype. This callback is optional. If
258** an application tries to send data when the transmit queue is full,
259** the data will anyways be dropped. The parameter is:
260**              Local CID
261**              TRUE if congested, FALSE if uncongested
262*/
263typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
264
265/* Callback prototype for number of packets completed events.
266** This callback notifies the application when Number of Completed Packets
267** event has been received.
268** This callback is originally designed for 3DG devices.
269** The parameter is:
270**          peer BD_ADDR
271*/
272typedef void (tL2CA_NOCP_CB) (BD_ADDR);
273
274/* Transmit complete callback protype. This callback is optional. If
275** set, L2CAP will call it when packets are sent or flushed. If the
276** count is 0xFFFF, it means all packets are sent for that CID (eRTM
277** mode only). The parameters are:
278**              Local CID
279**              Number of SDUs sent or dropped
280*/
281typedef void (tL2CA_TX_COMPLETE_CB) (UINT16, UINT16);
282
283/* Define the structure that applications use to register with
284** L2CAP. This structure includes callback functions. All functions
285** MUST be provided, with the exception of the "connect pending"
286** callback and "congestion status" callback.
287*/
288typedef struct
289{
290    tL2CA_CONNECT_IND_CB        *pL2CA_ConnectInd_Cb;
291    tL2CA_CONNECT_CFM_CB        *pL2CA_ConnectCfm_Cb;
292    tL2CA_CONNECT_PND_CB        *pL2CA_ConnectPnd_Cb;
293    tL2CA_CONFIG_IND_CB         *pL2CA_ConfigInd_Cb;
294    tL2CA_CONFIG_CFM_CB         *pL2CA_ConfigCfm_Cb;
295    tL2CA_DISCONNECT_IND_CB     *pL2CA_DisconnectInd_Cb;
296    tL2CA_DISCONNECT_CFM_CB     *pL2CA_DisconnectCfm_Cb;
297    tL2CA_QOS_VIOLATION_IND_CB  *pL2CA_QoSViolationInd_Cb;
298    tL2CA_DATA_IND_CB           *pL2CA_DataInd_Cb;
299    tL2CA_CONGESTION_STATUS_CB  *pL2CA_CongestionStatus_Cb;
300    tL2CA_TX_COMPLETE_CB        *pL2CA_TxComplete_Cb;
301
302} tL2CAP_APPL_INFO;
303
304/* Define the structure that applications use to create or accept
305** connections with enhanced retransmission mode.
306*/
307typedef struct
308{
309    UINT8       preferred_mode;
310    UINT8       allowed_modes;
311    UINT8       user_rx_pool_id;
312    UINT8       user_tx_pool_id;
313    UINT8       fcr_rx_pool_id;
314    UINT8       fcr_tx_pool_id;
315
316} tL2CAP_ERTM_INFO;
317
318#define L2CA_REGISTER(a,b,c)        L2CA_Register(a,(tL2CAP_APPL_INFO *)b)
319#define L2CA_DEREGISTER(a)          L2CA_Deregister(a)
320#define L2CA_CONNECT_REQ(a,b,c,d)   L2CA_ErtmConnectReq(a,b,c)
321#define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f)
322#define L2CA_CONFIG_REQ(a,b)        L2CA_ConfigReq(a,b)
323#define L2CA_CONFIG_RSP(a,b)        L2CA_ConfigRsp(a,b)
324#define L2CA_DISCONNECT_REQ(a)      L2CA_DisconnectReq(a)
325#define L2CA_DISCONNECT_RSP(a)      L2CA_DisconnectRsp(a)
326#define L2CA_DATA_WRITE(a, b)       L2CA_DataWrite(a, b)
327
328/*****************************************************************************
329**  External Function Declarations
330*****************************************************************************/
331#ifdef __cplusplus
332extern "C"
333{
334#endif
335
336/*******************************************************************************
337**
338** Function         L2CA_Register
339**
340** Description      Other layers call this function to register for L2CAP
341**                  services.
342**
343** Returns          PSM to use or zero if error. Typically, the PSM returned
344**                  is the same as was passed in, but for an outgoing-only
345**                  connection to a dynamic PSM, a "virtual" PSM is returned
346**                  and should be used in the calls to L2CA_ConnectReq() and
347**                  BTM_SetSecurityLevel().
348**
349*******************************************************************************/
350L2C_API extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
351
352/*******************************************************************************
353**
354** Function         L2CA_Deregister
355**
356** Description      Other layers call this function to deregister for L2CAP
357**                  services.
358**
359** Returns          void
360**
361*******************************************************************************/
362L2C_API extern void L2CA_Deregister (UINT16 psm);
363
364/*******************************************************************************
365**
366** Function         L2CA_AllocatePSM
367**
368** Description      Other layers call this function to find an unused PSM for L2CAP
369**                  services.
370**
371** Returns          PSM to use.
372**
373*******************************************************************************/
374L2C_API extern UINT16 L2CA_AllocatePSM(void);
375
376/*******************************************************************************
377**
378** Function         L2CA_ConnectReq
379**
380** Description      Higher layers call this function to create an L2CAP connection.
381**                  Note that the connection is not established at this time, but
382**                  connection establishment gets started. The callback function
383**                  will be invoked when connection establishes or fails.
384**
385** Returns          the CID of the connection, or 0 if it failed to start
386**
387*******************************************************************************/
388L2C_API extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr);
389
390/*******************************************************************************
391**
392** Function         L2CA_ConnectRsp
393**
394** Description      Higher layers call this function to accept an incoming
395**                  L2CAP connection, for which they had gotten an connect
396**                  indication callback.
397**
398** Returns          TRUE for success, FALSE for failure
399**
400*******************************************************************************/
401L2C_API extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
402                                        UINT16 result, UINT16 status);
403
404/*******************************************************************************
405**
406** Function         L2CA_ErtmConnectReq
407**
408** Description      Higher layers call this function to create an L2CAP connection
409**                  that needs to use Enhanced Retransmission Mode.
410**                  Note that the connection is not established at this time, but
411**                  connection establishment gets started. The callback function
412**                  will be invoked when connection establishes or fails.
413**
414** Returns          the CID of the connection, or 0 if it failed to start
415**
416*******************************************************************************/
417L2C_API extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
418                                           tL2CAP_ERTM_INFO *p_ertm_info);
419
420/*******************************************************************************
421**
422** Function         L2CA_ErtmConnectRsp
423**
424** Description      Higher layers call this function to accept an incoming
425**                  L2CAP connection, for which they had gotten an connect
426**                  indication callback, and for which the higher layer wants
427**                  to use Enhanced Retransmission Mode.
428**
429** Returns          TRUE for success, FALSE for failure
430**
431*******************************************************************************/
432L2C_API extern BOOLEAN  L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
433                                             UINT16 result, UINT16 status,
434                                             tL2CAP_ERTM_INFO *p_ertm_info);
435
436/*******************************************************************************
437**
438** Function         L2CA_ConfigReq
439**
440** Description      Higher layers call this function to send configuration.
441**
442** Returns          TRUE if configuration sent, else FALSE
443**
444*******************************************************************************/
445L2C_API extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
446
447/*******************************************************************************
448**
449** Function         L2CA_ConfigRsp
450**
451** Description      Higher layers call this function to send a configuration
452**                  response.
453**
454** Returns          TRUE if configuration response sent, else FALSE
455**
456*******************************************************************************/
457L2C_API extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
458
459/*******************************************************************************
460**
461** Function         L2CA_DisconnectReq
462**
463** Description      Higher layers call this function to disconnect a channel.
464**
465** Returns          TRUE if disconnect sent, else FALSE
466**
467*******************************************************************************/
468L2C_API extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
469
470/*******************************************************************************
471**
472** Function         L2CA_DisconnectRsp
473**
474** Description      Higher layers call this function to acknowledge the
475**                  disconnection of a channel.
476**
477** Returns          void
478**
479*******************************************************************************/
480L2C_API extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
481
482/*******************************************************************************
483**
484** Function         L2CA_DataWrite
485**
486** Description      Higher layers call this function to write data.
487**
488** Returns          L2CAP_DW_SUCCESS, if data accepted, else FALSE
489**                  L2CAP_DW_CONGESTED, if data accepted and the channel is congested
490**                  L2CAP_DW_FAILED, if error
491**
492*******************************************************************************/
493L2C_API extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
494
495/*******************************************************************************
496**
497** Function         L2CA_Ping
498**
499** Description      Higher layers call this function to send an echo request.
500**
501** Returns          TRUE if echo request sent, else FALSE.
502**
503*******************************************************************************/
504L2C_API extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
505
506/*******************************************************************************
507**
508** Function         L2CA_Echo
509**
510** Description      Higher layers call this function to send an echo request
511**                  with application-specific data.
512**
513** Returns          TRUE if echo request sent, else FALSE.
514**
515*******************************************************************************/
516L2C_API extern BOOLEAN  L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
517
518/*******************************************************************************
519**
520** Function         L2CA_SetIdleTimeout
521**
522** Description      Higher layers call this function to set the idle timeout for
523**                  a connection, or for all future connections. The "idle timeout"
524**                  is the amount of time that a connection can remain up with
525**                  no L2CAP channels on it. A timeout of zero means that the
526**                  connection will be torn down immediately when the last channel
527**                  is removed. A timeout of 0xFFFF means no timeout. Values are
528**                  in seconds.
529**
530** Returns          TRUE if command succeeded, FALSE if failed
531**
532*******************************************************************************/
533L2C_API extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
534                                            BOOLEAN is_global);
535
536/*******************************************************************************
537**
538** Function         L2CA_SetIdleTimeoutByBdAddr
539**
540** Description      Higher layers call this function to set the idle timeout for
541**                  a connection. The "idle timeout" is the amount of time that
542**                  a connection can remain up with no L2CAP channels on it.
543**                  A timeout of zero means that the connection will be torn
544**                  down immediately when the last channel is removed.
545**                  A timeout of 0xFFFF means no timeout. Values are in seconds.
546**                  A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
547**                  then the idle timeouts for all active l2cap links will be
548**                  changed.
549**
550** Returns          TRUE if command succeeded, FALSE if failed
551**
552** NOTE             This timeout applies to all logical channels active on the
553**                  ACL link.
554*******************************************************************************/
555L2C_API extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout);
556
557/*******************************************************************************
558**
559** Function         L2CA_SetTraceLevel
560**
561** Description      This function sets the trace level for L2CAP. If called with
562**                  a value of 0xFF, it simply reads the current trace level.
563**
564** Returns          the new (current) trace level
565**
566*******************************************************************************/
567L2C_API extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
568
569/*******************************************************************************
570**
571** Function     L2CA_SetDesireRole
572**
573** Description  This function sets the desire role for L2CAP.
574**              If the new role is L2CAP_ROLE_ALLOW_SWITCH, allow switch on
575**              HciCreateConnection.
576**              If the new role is L2CAP_ROLE_DISALLOW_SWITCH, do not allow switch on
577**              HciCreateConnection.
578**
579**              If the new role is a valid role (HCI_ROLE_MASTER or HCI_ROLE_SLAVE),
580**              the desire role is set to the new value. Otherwise, it is not changed.
581**
582** Returns      the new (current) role
583**
584*******************************************************************************/
585L2C_API extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
586
587/*******************************************************************************
588**
589** Function     L2CA_LocalLoopbackReq
590**
591** Description  This function sets up a CID for local loopback
592**
593** Returns      CID of 0 if none.
594**
595*******************************************************************************/
596L2C_API extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr);
597
598/*******************************************************************************
599**
600** Function     L2CA_FlushChannel
601**
602** Description  This function flushes none, some or all buffers queued up
603**              for xmission for a particular CID. If called with
604**              L2CAP_FLUSH_CHANS_GET (0), it simply returns the number
605**              of buffers queued for that CID L2CAP_FLUSH_CHANS_ALL (0xffff)
606**              flushes all buffers.  All other values specifies the maximum
607**              buffers to flush.
608**
609** Returns      Number of buffers left queued for that CID
610**
611*******************************************************************************/
612L2C_API extern UINT16   L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush);
613
614
615/*******************************************************************************
616**
617** Function         L2CA_SetAclPriority
618**
619** Description      Sets the transmission priority for an ACL channel.
620**                  (For initial implementation only two values are valid.
621**                  L2CAP_PRIORITY_NORMAL and L2CAP_PRIORITY_HIGH).
622**
623** Returns          TRUE if a valid channel, else FALSE
624**
625*******************************************************************************/
626L2C_API extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority);
627
628/*******************************************************************************
629**
630** Function         L2CA_FlowControl
631**
632** Description      Higher layers call this function to flow control a channel.
633**
634**                  data_enabled - TRUE data flows, FALSE data is stopped
635**
636** Returns          TRUE if valid channel, else FALSE
637**
638*******************************************************************************/
639L2C_API extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled);
640
641/*******************************************************************************
642**
643** Function         L2CA_SendTestSFrame
644**
645** Description      Higher layers call this function to send a test S-frame.
646**
647** Returns          TRUE if valid Channel, else FALSE
648**
649*******************************************************************************/
650L2C_API extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type,
651                                            UINT8 back_track);
652
653/*******************************************************************************
654**
655** Function         L2CA_SetTxPriority
656**
657** Description      Sets the transmission priority for a channel. (FCR Mode)
658**
659** Returns          TRUE if a valid channel, else FALSE
660**
661*******************************************************************************/
662L2C_API extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority);
663
664/*******************************************************************************
665**
666** Function         L2CA_RegForNoCPEvt
667**
668** Description      Register callback for Number of Completed Packets event.
669**
670** Input Param      p_cb - callback for Number of completed packets event
671**                  p_bda - BT address of remote device
672**
673** Returns
674**
675*******************************************************************************/
676L2C_API extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda);
677
678/*******************************************************************************
679**
680** Function         L2CA_SetChnlDataRate
681**
682** Description      Sets the tx/rx data rate for a channel.
683**
684** Returns          TRUE if a valid channel, else FALSE
685**
686*******************************************************************************/
687L2C_API extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx);
688
689typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
690
691/*******************************************************************************
692**
693** Function         L2CA_SetFlushTimeout
694**
695** Description      This function set the automatic flush time out in Baseband
696**                  for ACL-U packets.
697**                  BdAddr : the remote BD address of ACL link. If it is BT_DB_ANY
698**                           then the flush time out will be applied to all ACL link.
699**                  FlushTimeout: flush time out in ms
700**                           0x0000 : No automatic flush
701**                           L2CAP_NO_RETRANSMISSION : No retransmission
702**                           0x0002 - 0xFFFE : flush time out, if (flush_tout*8)+3/5)
703**                                    <= HCI_MAX_AUTO_FLUSH_TOUT (in 625us slot).
704**                                    Otherwise, return FALSE.
705**                           L2CAP_NO_AUTOMATIC_FLUSH : No automatic flush
706**
707** Returns          TRUE if command succeeded, FALSE if failed
708**
709** NOTE             This flush timeout applies to all logical channels active on the
710**                  ACL link.
711*******************************************************************************/
712L2C_API extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
713
714/*******************************************************************************
715**
716** Function         L2CA_DataWriteEx
717**
718** Description      Higher layers call this function to write data with extended
719**                  flags.
720**                  flags : L2CAP_FLUSHABLE_CH_BASED
721**                          L2CAP_FLUSHABLE_PKT
722**                          L2CAP_NON_FLUSHABLE_PKT
723**
724** Returns          L2CAP_DW_SUCCESS, if data accepted, else FALSE
725**                  L2CAP_DW_CONGESTED, if data accepted and the channel is congested
726**                  L2CAP_DW_FAILED, if error
727**
728*******************************************************************************/
729L2C_API extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags);
730
731/*******************************************************************************
732**
733** Function         L2CA_SetChnlFlushability
734**
735** Description      Higher layers call this function to set a channels
736**                  flushability flags
737**
738** Returns          TRUE if CID found, else FALSE
739**
740*******************************************************************************/
741L2C_API extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable);
742
743/*******************************************************************************
744**
745**  Function         L2CA_GetPeerFeatures
746**
747**  Description      Get a peers features and fixed channel map
748**
749**  Parameters:      BD address of the peer
750**                   Pointers to features and channel mask storage area
751**
752**  Return value:    TRUE if peer is connected
753**
754*******************************************************************************/
755L2C_API extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask);
756
757/*******************************************************************************
758**
759**  Function         L2CA_GetBDAddrbyHandle
760**
761**  Description      Get BD address for the given HCI handle
762**
763**  Parameters:      HCI handle
764**                   BD address of the peer
765**
766**  Return value:    TRUE if found lcb for the given handle, FALSE otherwise
767**
768*******************************************************************************/
769L2C_API extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
770
771/*******************************************************************************
772**
773**  Function         L2CA_GetChnlFcrMode
774**
775**  Description      Get the channel FCR mode
776**
777**  Parameters:      Local CID
778**
779**  Return value:    Channel mode
780**
781*******************************************************************************/
782L2C_API extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
783
784
785/*******************************************************************************
786**
787**                      UCD callback prototypes
788**
789*******************************************************************************/
790
791/* UCD discovery. Parameters are
792**      BD Address of remote
793**      Data Type
794**      Data
795*/
796#define L2CAP_UCD_INFO_TYPE_RECEPTION   0x01
797#define L2CAP_UCD_INFO_TYPE_MTU         0x02
798
799typedef void (tL2CA_UCD_DISCOVER_CB) (BD_ADDR, UINT8, UINT32);
800
801/* UCD data received. Parameters are
802**      BD Address of remote
803**      Pointer to buffer with data
804*/
805typedef void (tL2CA_UCD_DATA_CB) (BD_ADDR, BT_HDR *);
806
807/* Congestion status callback protype. This callback is optional. If
808** an application tries to send data when the transmit queue is full,
809** the data will anyways be dropped. The parameter is:
810**              remote BD_ADDR
811**              TRUE if congested, FALSE if uncongested
812*/
813typedef void (tL2CA_UCD_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
814
815/* UCD registration info (the callback addresses and PSM)
816*/
817typedef struct
818{
819    tL2CA_UCD_DISCOVER_CB           *pL2CA_UCD_Discover_Cb;
820    tL2CA_UCD_DATA_CB               *pL2CA_UCD_Data_Cb;
821    tL2CA_UCD_CONGESTION_STATUS_CB  *pL2CA_UCD_Congestion_Status_Cb;
822} tL2CAP_UCD_CB_INFO;
823
824/*******************************************************************************
825**
826**  Function        L2CA_UcdRegister
827**
828**  Description     Register PSM on UCD.
829**
830**  Parameters:     tL2CAP_UCD_CB_INFO
831**
832**  Return value:   TRUE if successs
833**
834*******************************************************************************/
835L2C_API extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info );
836
837/*******************************************************************************
838**
839**  Function        L2CA_UcdDeregister
840**
841**  Description     Deregister PSM on UCD.
842**
843**  Parameters:     PSM
844**
845**  Return value:   TRUE if successs
846**
847*******************************************************************************/
848L2C_API extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm );
849
850/*******************************************************************************
851**
852**  Function        L2CA_UcdDiscover
853**
854**  Description     Discover UCD of remote device.
855**
856**  Parameters:     PSM
857**                  BD_ADDR of remote device
858**                  info_type : L2CAP_UCD_INFO_TYPE_RECEPTION
859**                              L2CAP_UCD_INFO_TYPE_MTU
860**
861**
862**  Return value:   TRUE if successs
863**
864*******************************************************************************/
865L2C_API extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type );
866
867/*******************************************************************************
868**
869**  Function        L2CA_UcdDataWrite
870**
871**  Description     Send UCD to remote device
872**
873**  Parameters:     PSM
874**                  BD Address of remote
875**                  Pointer to buffer of type BT_HDR
876**                  flags : L2CAP_FLUSHABLE_CH_BASED
877**                          L2CAP_FLUSHABLE_PKT
878**                          L2CAP_NON_FLUSHABLE_PKT
879**
880** Return value     L2CAP_DW_SUCCESS, if data accepted
881**                  L2CAP_DW_FAILED,  if error
882**
883*******************************************************************************/
884L2C_API extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags);
885
886/*******************************************************************************
887**
888**  Function        L2CA_UcdSetIdleTimeout
889**
890**  Description     Set UCD Idle timeout.
891**
892**  Parameters:     BD Addr
893**                  Timeout in second
894**
895**  Return value:   TRUE if successs
896**
897*******************************************************************************/
898L2C_API extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout );
899
900/*******************************************************************************
901**
902** Function         L2CA_UCDSetTxPriority
903**
904** Description      Sets the transmission priority for a connectionless channel.
905**
906** Returns          TRUE if a valid channel, else FALSE
907**
908*******************************************************************************/
909L2C_API extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
910
911
912/*******************************************************************************
913**
914**                      Fixed Channel callback prototypes
915**
916*******************************************************************************/
917
918/* Fixed channel connected and disconnected. Parameters are
919**      BD Address of remote
920**      TRUE if channel is connected, FALSE if disconnected
921**      Reason for connection failure
922**      transport : physical transport, BR/EDR or LE
923*/
924typedef void (tL2CA_FIXED_CHNL_CB) (BD_ADDR, BOOLEAN, UINT16, tBT_TRANSPORT);
925
926/* Signalling data received. Parameters are
927**      BD Address of remote
928**      Pointer to buffer with data
929*/
930typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR, BT_HDR *);
931
932/* Congestion status callback protype. This callback is optional. If
933** an application tries to send data when the transmit queue is full,
934** the data will anyways be dropped. The parameter is:
935**      remote BD_ADDR
936**      TRUE if congested, FALSE if uncongested
937*/
938typedef void (tL2CA_FIXED_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
939
940/* Fixed channel registration info (the callback addresses and channel config)
941*/
942typedef struct
943{
944    tL2CA_FIXED_CHNL_CB    *pL2CA_FixedConn_Cb;
945    tL2CA_FIXED_DATA_CB    *pL2CA_FixedData_Cb;
946    tL2CA_FIXED_CONGESTION_STATUS_CB *pL2CA_FixedCong_Cb;
947    tL2CAP_FCR_OPTS         fixed_chnl_opts;
948
949    UINT16                  default_idle_tout;
950} tL2CAP_FIXED_CHNL_REG;
951
952
953#if (L2CAP_NUM_FIXED_CHNLS > 0)
954/*******************************************************************************
955**
956**  Function        L2CA_RegisterFixedChannel
957**
958**  Description     Register a fixed channel.
959**
960**  Parameters:     Fixed Channel #
961**                  Channel Callbacks and config
962**
963**  Return value:   TRUE if registered OK
964**
965*******************************************************************************/
966L2C_API extern BOOLEAN  L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg);
967
968/*******************************************************************************
969**
970**  Function        L2CA_ConnectFixedChnl
971**
972**  Description     Connect an fixed signalling channel to a remote device.
973**
974**  Parameters:     Fixed CID
975**                  BD Address of remote
976**
977**  Return value:   TRUE if connection started
978**
979*******************************************************************************/
980L2C_API extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr);
981
982/*******************************************************************************
983**
984**  Function        L2CA_SendFixedChnlData
985**
986**  Description     Write data on a fixed signalling channel.
987**
988**  Parameters:     Fixed CID
989**                  BD Address of remote
990**                  Pointer to buffer of type BT_HDR
991**
992** Return value     L2CAP_DW_SUCCESS, if data accepted
993**                  L2CAP_DW_FAILED,  if error
994**
995*******************************************************************************/
996L2C_API extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf);
997
998/*******************************************************************************
999**
1000**  Function        L2CA_RemoveFixedChnl
1001**
1002**  Description     Remove a fixed channel to a remote device.
1003**
1004**  Parameters:     Fixed CID
1005**                  BD Address of remote
1006**                  Idle timeout to use (or 0xFFFF if don't care)
1007**
1008**  Return value:   TRUE if channel removed
1009**
1010*******************************************************************************/
1011L2C_API extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda);
1012
1013/*******************************************************************************
1014**
1015** Function         L2CA_SetFixedChannelTout
1016**
1017** Description      Higher layers call this function to set the idle timeout for
1018**                  a fixed channel. The "idle timeout" is the amount of time that
1019**                  a connection can remain up with no L2CAP channels on it.
1020**                  A timeout of zero means that the connection will be torn
1021**                  down immediately when the last channel is removed.
1022**                  A timeout of 0xFFFF means no timeout. Values are in seconds.
1023**                  A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
1024**                  then the idle timeouts for all active l2cap links will be
1025**                  changed.
1026**
1027** Returns          TRUE if command succeeded, FALSE if failed
1028**
1029*******************************************************************************/
1030L2C_API extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
1031
1032#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
1033
1034/*******************************************************************************
1035**
1036** Function     L2CA_GetCurrentConfig
1037**
1038** Description  This function returns configurations of L2CAP channel
1039**              pp_our_cfg : pointer of our saved configuration options
1040**              p_our_cfg_bits : valid config in bitmap
1041**              pp_peer_cfg: pointer of peer's saved configuration options
1042**              p_peer_cfg_bits : valid config in bitmap
1043**
1044** Returns      TRUE if successful
1045**
1046*******************************************************************************/
1047L2C_API extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
1048                                              tL2CAP_CFG_INFO **pp_our_cfg,  tL2CAP_CH_CFG_BITS *p_our_cfg_bits,
1049                                              tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits);
1050
1051#if (L2CAP_CORRUPT_ERTM_PKTS == TRUE)
1052/*******************************************************************************
1053**
1054** Function         L2CA_SetupErtmTest
1055**
1056** Description      This function is used for testing purposes only.
1057**                  It corrupts or drops one or more packets used with ERTM channels.
1058**
1059** Parameters
1060**                  cid - channel ID  (0 uses RFCOMM PSM's CID)
1061**
1062**                  type - type of test to run (L2CAP_FCR_TTYPE_CORR_IFRAMES
1063**                                              L2CAP_FCR_TTYPE_CORR_SFRAME
1064**                                              L2CAP_FCR_TTYPE_STOP_TEST
1065**                                              L2CAP_FCR_TTYPE_GET_CID - returns rfcomm cid only)
1066**
1067**                  is_rx  - TRUE to corrupt Rx packet, FALSE for Tx packet)
1068**
1069**                  freq - L2CAP_FCR_FREQ_RANDOM    (turns on random corruptions/drops)
1070**                         L2CAP_FCR_FREQ_NORMAL    (turns on test with "count" corruptions/drops)
1071**
1072**                  count - number of packets in a row to drop or corrupt
1073**
1074** Returns          CID of channel running test
1075**
1076*******************************************************************************/
1077L2C_API extern UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count);
1078
1079/*******************************************************************************
1080**
1081** Function         L2CA_SendPolledSFrame
1082**
1083** Description      This function is used for testing purposes only.
1084**                  It Sends a Polled RR or RNR to the peer
1085**
1086** Parameters
1087**                  cid - channel ID
1088**
1089**                  sup_type - (L2CAP_FCR_SUP_RR or L2CAP_FCR_SUP_RNR)
1090**
1091** Returns          void
1092**
1093*******************************************************************************/
1094L2C_API extern void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type);
1095
1096/*******************************************************************************
1097**
1098** Function         L2CA_BypassSFrame
1099**
1100** Description      This function is used for testing purposes only.
1101**                  It skips sending 'count' S-Frames.
1102**
1103** Parameters
1104**                  cid - channel ID
1105**
1106**                  count - Number of S-Frames to skip sending
1107**
1108** Returns          void
1109**
1110*******************************************************************************/
1111L2C_API extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count);
1112
1113#endif /* (L2CAP_CORRUPT_ERTM_PKTS == TRUE) */
1114
1115
1116#if (BLE_INCLUDED == TRUE)
1117/*******************************************************************************
1118**
1119**  Function        L2CA_CancelBleConnectReq
1120**
1121**  Description     Cancel a pending connection attempt to a BLE device.
1122**
1123**  Parameters:     BD Address of remote
1124**
1125**  Return value:   TRUE if connection was cancelled
1126**
1127*******************************************************************************/
1128L2C_API extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda);
1129
1130/*******************************************************************************
1131**
1132**  Function        L2CA_UpdateBleConnParams
1133**
1134**  Description     Update BLE connection parameters.
1135**
1136**  Parameters:     BD Address of remote
1137**
1138**  Return value:   TRUE if update started
1139**
1140*******************************************************************************/
1141L2C_API extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int,
1142                                                          UINT16 max_int, UINT16 latency, UINT16 timeout);
1143
1144/*******************************************************************************
1145**
1146**  Function        L2CA_EnableUpdateBleConnParams
1147**
1148**  Description     Update BLE connection parameters.
1149**
1150**  Parameters:     BD Address of remote
1151**                  enable flag
1152**
1153**  Return value:   TRUE if update started
1154**
1155*******************************************************************************/
1156L2C_API extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
1157
1158/*******************************************************************************
1159**
1160** Function         L2CA_GetBleConnRole
1161**
1162** Description      This function returns the connection role.
1163**
1164** Returns          link role.
1165**
1166*******************************************************************************/
1167L2C_API extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
1168
1169/*******************************************************************************
1170**
1171** Function         L2CA_GetDisconnectReason
1172**
1173** Description      This function returns the disconnect reason code.
1174**
1175**  Parameters:     BD Address of remote
1176**                         Physical transport for the L2CAP connection (BR/EDR or LE)
1177**
1178** Returns          disconnect reason
1179**
1180*******************************************************************************/
1181L2C_API extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport);
1182
1183#endif /* (BLE_INCLUDED == TRUE) */
1184
1185#ifdef __cplusplus
1186}
1187#endif
1188
1189#endif  /* L2C_API_H */
1190