blob: 9674cbc33161f9c672eb0a1e664ed9871748f398 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
Avish Shaha408eb72016-06-22 06:47:20 +05303 * Copyright (C) 2003-2016 Broadcom Corporation
The Android Open Source Project5738f832012-12-12 16:00:35 -08004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 * This file contains interfaces which are internal to AVCTP.
22 *
23 ******************************************************************************/
24#ifndef AVCT_INT_H
25#define AVCT_INT_H
26
The Android Open Source Project5738f832012-12-12 16:00:35 -080027#include "avct_api.h"
28#include "avct_defs.h"
Myles Watson911d1ae2016-11-28 16:44:40 -080029#include "bt_common.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080030#include "l2c_api.h"
Myles Watson911d1ae2016-11-28 16:44:40 -080031#include "osi/include/fixed_queue.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080032
33/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -080034 * constants
35 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080036
37/* lcb state machine events */
38enum {
Myles Watson911d1ae2016-11-28 16:44:40 -080039 AVCT_LCB_UL_BIND_EVT,
40 AVCT_LCB_UL_UNBIND_EVT,
41 AVCT_LCB_UL_MSG_EVT,
42 AVCT_LCB_INT_CLOSE_EVT,
43 AVCT_LCB_LL_OPEN_EVT,
44 AVCT_LCB_LL_CLOSE_EVT,
45 AVCT_LCB_LL_MSG_EVT,
46 AVCT_LCB_LL_CONG_EVT
The Android Open Source Project5738f832012-12-12 16:00:35 -080047};
48
The Android Open Source Project5738f832012-12-12 16:00:35 -080049/* "states" used for L2CAP channel */
Myles Watson911d1ae2016-11-28 16:44:40 -080050#define AVCT_CH_IDLE 0 /* No connection */
51#define AVCT_CH_CONN 1 /* Waiting for connection confirm */
52#define AVCT_CH_CFG 2 /* Waiting for configuration complete */
53#define AVCT_CH_OPEN 3 /* Channel opened */
The Android Open Source Project5738f832012-12-12 16:00:35 -080054
55/* "no event" indicator used by ccb dealloc */
Myles Watson911d1ae2016-11-28 16:44:40 -080056#define AVCT_NO_EVT 0xFF
The Android Open Source Project5738f832012-12-12 16:00:35 -080057
58/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -080059 * data types
60 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080061/* sub control block type - common data members for tAVCT_LCB and tAVCT_BCB */
62typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -080063 uint16_t peer_mtu; /* peer l2c mtu */
64 uint16_t ch_result; /* L2CAP connection result value */
65 uint16_t ch_lcid; /* L2CAP channel LCID */
66 uint8_t allocated; /* 0, not allocated. index+1, otherwise. */
67 uint8_t state; /* The state machine state */
68 uint8_t ch_state; /* L2CAP channel state */
69 uint8_t ch_flags; /* L2CAP configuration flags */
The Android Open Source Project5738f832012-12-12 16:00:35 -080070} tAVCT_SCB;
71
72/* link control block type */
73typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -080074 uint16_t peer_mtu; /* peer l2c mtu */
75 uint16_t ch_result; /* L2CAP connection result value */
76 uint16_t ch_lcid; /* L2CAP channel LCID */
77 uint8_t allocated; /* 0, not allocated. index+1, otherwise. */
78 uint8_t state; /* The state machine state */
79 uint8_t ch_state; /* L2CAP channel state */
80 uint8_t ch_flags; /* L2CAP configuration flags */
81 BT_HDR* p_rx_msg; /* Message being reassembled */
82 uint16_t conflict_lcid; /* L2CAP channel LCID */
83 BD_ADDR peer_addr; /* BD address of peer */
84 fixed_queue_t* tx_q; /* Transmit data buffer queue */
85 bool cong; /* true, if congested */
The Android Open Source Project5738f832012-12-12 16:00:35 -080086} tAVCT_LCB;
87
88/* browse control block type */
89typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -080090 uint16_t peer_mtu; /* peer l2c mtu */
91 uint16_t ch_result; /* L2CAP connection result value */
92 uint16_t ch_lcid; /* L2CAP channel LCID */
93 uint8_t allocated; /* 0, not allocated. index+1, otherwise. */
94 uint8_t state; /* The state machine state */
95 uint8_t ch_state; /* L2CAP channel state */
96 uint8_t ch_flags; /* L2CAP configuration flags */
97 BT_HDR* p_tx_msg; /* Message to be sent - in case the browsing channel is not
98 open when MsgReg is called */
99 uint8_t ch_close; /* CCB index+1, if CCB initiated channel close */
100 BD_ADDR peer_addr; /* BD address of peer */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800101} tAVCT_BCB;
102
Myles Watson911d1ae2016-11-28 16:44:40 -0800103#define AVCT_ALOC_LCB 0x01
104#define AVCT_ALOC_BCB 0x02
The Android Open Source Project5738f832012-12-12 16:00:35 -0800105/* connection control block */
106typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -0800107 tAVCT_CC cc; /* parameters from connection creation */
108 tAVCT_LCB* p_lcb; /* Associated LCB */
109 tAVCT_BCB* p_bcb; /* associated BCB */
110 bool ch_close; /* Whether CCB initiated channel close */
111 uint8_t allocated; /* Whether LCB/BCB is allocated */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800112} tAVCT_CCB;
113
114/* data type associated with UL_MSG_EVT */
115typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -0800116 BT_HDR* p_buf;
117 tAVCT_CCB* p_ccb;
118 uint8_t label;
119 uint8_t cr;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800120} tAVCT_UL_MSG;
121
122/* union associated with lcb state machine events */
123typedef union {
Myles Watson911d1ae2016-11-28 16:44:40 -0800124 tAVCT_UL_MSG ul_msg;
125 BT_HDR* p_buf;
126 tAVCT_CCB* p_ccb;
127 uint16_t result;
128 bool cong;
129 uint8_t err_code;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800130} tAVCT_LCB_EVT;
131
132/* Control block for AVCT */
133typedef struct {
Myles Watson911d1ae2016-11-28 16:44:40 -0800134 tAVCT_LCB lcb[AVCT_NUM_LINKS]; /* link control blocks */
135 tAVCT_BCB bcb[AVCT_NUM_LINKS]; /* browse control blocks */
136 tAVCT_CCB ccb[AVCT_NUM_CONN]; /* connection control blocks */
137 uint16_t mtu; /* our L2CAP MTU */
138 uint16_t mtu_br; /* our L2CAP MTU for the Browsing channel */
139 uint8_t trace_level; /* trace level */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800140} tAVCT_CB;
141
142/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800143 * function declarations
144 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -0800145
146/* LCB function declarations */
Myles Watson911d1ae2016-11-28 16:44:40 -0800147extern void avct_lcb_event(tAVCT_LCB* p_lcb, uint8_t event,
148 tAVCT_LCB_EVT* p_data);
149extern void avct_bcb_event(tAVCT_BCB* p_bcb, uint8_t event,
150 tAVCT_LCB_EVT* p_data);
151extern void avct_close_bcb(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
152extern tAVCT_LCB* avct_lcb_by_bcb(tAVCT_BCB* p_bcb);
153extern tAVCT_BCB* avct_bcb_by_lcb(tAVCT_LCB* p_lcb);
154extern uint8_t avct_bcb_get_last_ccb_index(tAVCT_BCB* p_bcb,
155 tAVCT_CCB* p_ccb_last);
156extern tAVCT_BCB* avct_bcb_by_lcid(uint16_t lcid);
157extern tAVCT_LCB* avct_lcb_by_bd(BD_ADDR bd_addr);
158extern tAVCT_LCB* avct_lcb_alloc(BD_ADDR bd_addr);
159extern void avct_lcb_dealloc(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
160extern tAVCT_LCB* avct_lcb_by_lcid(uint16_t lcid);
161extern tAVCT_CCB* avct_lcb_has_pid(tAVCT_LCB* p_lcb, uint16_t pid);
162extern bool avct_lcb_last_ccb(tAVCT_LCB* p_lcb, tAVCT_CCB* p_ccb_last);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800163
164/* LCB action functions */
Myles Watson911d1ae2016-11-28 16:44:40 -0800165extern void avct_lcb_chnl_open(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
166extern void avct_lcb_unbind_disc(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
167extern void avct_lcb_open_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
168extern void avct_lcb_open_fail(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
169extern void avct_lcb_close_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
170extern void avct_lcb_close_cfm(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
171extern void avct_lcb_bind_conn(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
172extern void avct_lcb_chk_disc(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
173extern void avct_lcb_chnl_disc(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
174extern void avct_lcb_bind_fail(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
175extern void avct_lcb_cong_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
176extern void avct_lcb_discard_msg(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
177extern void avct_lcb_send_msg(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
178extern void avct_lcb_msg_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
179extern void avct_lcb_free_msg_ind(tAVCT_LCB* p_lcb, tAVCT_LCB_EVT* p_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800180
181/* BCB action functions */
Myles Watson911d1ae2016-11-28 16:44:40 -0800182typedef void (*tAVCT_BCB_ACTION)(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
183extern void avct_bcb_chnl_open(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
184extern void avct_bcb_unbind_disc(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
185extern void avct_bcb_open_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
186extern void avct_bcb_open_fail(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
187extern void avct_bcb_close_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
188extern void avct_bcb_close_cfm(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
189extern void avct_bcb_bind_conn(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
190extern void avct_bcb_chk_disc(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
191extern void avct_bcb_chnl_disc(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
192extern void avct_bcb_bind_fail(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
193extern void avct_bcb_cong_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
194extern void avct_bcb_discard_msg(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
195extern void avct_bcb_send_msg(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
196extern void avct_bcb_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
197extern void avct_bcb_free_msg_ind(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800198
Myles Watson911d1ae2016-11-28 16:44:40 -0800199extern void avct_bcb_dealloc(tAVCT_BCB* p_bcb, tAVCT_LCB_EVT* p_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800200
201extern const tAVCT_BCB_ACTION avct_bcb_action[];
Marie Janssend19e0782016-07-15 12:48:27 -0700202extern const uint8_t avct_lcb_pkt_type_len[];
The Android Open Source Project5738f832012-12-12 16:00:35 -0800203extern const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800204
205/* CCB function declarations */
Myles Watson911d1ae2016-11-28 16:44:40 -0800206extern tAVCT_CCB* avct_ccb_alloc(tAVCT_CC* p_cc);
207extern void avct_ccb_dealloc(tAVCT_CCB* p_ccb, uint8_t event, uint16_t result,
208 BD_ADDR bd_addr);
209extern uint8_t avct_ccb_to_idx(tAVCT_CCB* p_ccb);
210extern tAVCT_CCB* avct_ccb_by_idx(uint8_t idx);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800211
212/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800213 * global data
214 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -0800215
216/* Main control block */
June R. Tate-Gans24933b52014-09-24 15:25:02 -0700217extern tAVCT_CB avct_cb;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800218
219/* L2CAP callback registration structure */
220extern const tL2CAP_APPL_INFO avct_l2c_appl;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800221extern const tL2CAP_APPL_INFO avct_l2c_br_appl;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800222
The Android Open Source Project5738f832012-12-12 16:00:35 -0800223#endif /* AVCT_INT_H */