1/****************************************************************************** 2 * 3 * Copyright (C) 2003-2012 Broadcom Corporation 4 * 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 27#include "gki.h" 28#include "avct_api.h" 29#include "avct_defs.h" 30#include "l2c_api.h" 31 32/***************************************************************************** 33** constants 34*****************************************************************************/ 35 36/* lcb state machine events */ 37enum { 38 AVCT_LCB_UL_BIND_EVT, 39 AVCT_LCB_UL_UNBIND_EVT, 40 AVCT_LCB_UL_MSG_EVT, 41 AVCT_LCB_INT_CLOSE_EVT, 42 AVCT_LCB_LL_OPEN_EVT, 43 AVCT_LCB_LL_CLOSE_EVT, 44 AVCT_LCB_LL_MSG_EVT, 45 AVCT_LCB_LL_CONG_EVT 46}; 47 48 49/* "states" used for L2CAP channel */ 50#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 */ 54 55/* "no event" indicator used by ccb dealloc */ 56#define AVCT_NO_EVT 0xFF 57 58/***************************************************************************** 59** data types 60*****************************************************************************/ 61/* sub control block type - common data members for tAVCT_LCB and tAVCT_BCB */ 62typedef struct { 63 UINT16 peer_mtu; /* peer l2c mtu */ 64 UINT16 ch_result; /* L2CAP connection result value */ 65 UINT16 ch_lcid; /* L2CAP channel LCID */ 66 UINT8 allocated; /* 0, not allocated. index+1, otherwise. */ 67 UINT8 state; /* The state machine state */ 68 UINT8 ch_state; /* L2CAP channel state */ 69 UINT8 ch_flags; /* L2CAP configuration flags */ 70} tAVCT_SCB; 71 72/* link control block type */ 73typedef struct { 74 UINT16 peer_mtu; /* peer l2c mtu */ 75 UINT16 ch_result; /* L2CAP connection result value */ 76 UINT16 ch_lcid; /* L2CAP channel LCID */ 77 UINT8 allocated; /* 0, not allocated. index+1, otherwise. */ 78 UINT8 state; /* The state machine state */ 79 UINT8 ch_state; /* L2CAP channel state */ 80 UINT8 ch_flags; /* L2CAP configuration flags */ 81 BT_HDR *p_rx_msg; /* Message being reassembled */ 82 UINT16 conflict_lcid; /* L2CAP channel LCID */ 83 BD_ADDR peer_addr; /* BD address of peer */ 84 BUFFER_Q tx_q; /* Transmit data buffer queue */ 85 BOOLEAN cong; /* TRUE, if congested */ 86} tAVCT_LCB; 87 88/* browse control block type */ 89typedef struct { 90 UINT16 peer_mtu; /* peer l2c mtu */ 91 UINT16 ch_result; /* L2CAP connection result value */ 92 UINT16 ch_lcid; /* L2CAP channel LCID */ 93 UINT8 allocated; /* 0, not allocated. index+1, otherwise. */ 94 UINT8 state; /* The state machine state */ 95 UINT8 ch_state; /* L2CAP channel state */ 96 UINT8 ch_flags; /* L2CAP configuration flags */ 97 BT_HDR *p_tx_msg; /* Message to be sent - in case the browsing channel is not open when MsgReg is called */ 98 UINT8 ch_close; /* CCB index+1, if CCB initiated channel close */ 99} tAVCT_BCB; 100 101#define AVCT_ALOC_LCB 0x01 102#define AVCT_ALOC_BCB 0x02 103/* connection control block */ 104typedef struct { 105 tAVCT_CC cc; /* parameters from connection creation */ 106 tAVCT_LCB *p_lcb; /* Associated LCB */ 107 tAVCT_BCB *p_bcb; /* associated BCB */ 108 BOOLEAN ch_close; /* Whether CCB initiated channel close */ 109 UINT8 allocated; /* Whether LCB/BCB is allocated */ 110} tAVCT_CCB; 111 112/* data type associated with UL_MSG_EVT */ 113typedef struct { 114 BT_HDR *p_buf; 115 tAVCT_CCB *p_ccb; 116 UINT8 label; 117 UINT8 cr; 118} tAVCT_UL_MSG; 119 120/* union associated with lcb state machine events */ 121typedef union { 122 tAVCT_UL_MSG ul_msg; 123 BT_HDR *p_buf; 124 tAVCT_CCB *p_ccb; 125 UINT16 result; 126 BOOLEAN cong; 127 UINT8 err_code; 128} tAVCT_LCB_EVT; 129 130/* Control block for AVCT */ 131typedef struct { 132 tAVCT_LCB lcb[AVCT_NUM_LINKS]; /* link control blocks */ 133 tAVCT_BCB bcb[AVCT_NUM_LINKS]; /* browse control blocks */ 134 tAVCT_CCB ccb[AVCT_NUM_CONN]; /* connection control blocks */ 135 UINT16 mtu; /* our L2CAP MTU */ 136 UINT16 mtu_br; /* our L2CAP MTU for the Browsing channel */ 137 UINT8 trace_level; /* trace level */ 138} tAVCT_CB; 139 140/***************************************************************************** 141** function declarations 142*****************************************************************************/ 143 144/* LCB function declarations */ 145extern void avct_lcb_event(tAVCT_LCB *p_lcb, UINT8 event, tAVCT_LCB_EVT *p_data); 146#if (AVCT_BROWSE_INCLUDED == TRUE) 147extern void avct_bcb_event(tAVCT_BCB *p_bcb, UINT8 event, tAVCT_LCB_EVT *p_data); 148extern void avct_close_bcb(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 149extern tAVCT_LCB *avct_lcb_by_bcb(tAVCT_BCB *p_bcb); 150extern tAVCT_BCB *avct_bcb_by_lcb(tAVCT_LCB *p_lcb); 151extern BOOLEAN avct_bcb_last_ccb(tAVCT_BCB *p_bcb, tAVCT_CCB *p_ccb_last); 152extern tAVCT_BCB *avct_bcb_by_lcid(UINT16 lcid); 153#endif 154extern tAVCT_LCB *avct_lcb_by_bd(BD_ADDR bd_addr); 155extern tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr); 156extern void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 157extern tAVCT_LCB *avct_lcb_by_lcid(UINT16 lcid); 158extern tAVCT_CCB *avct_lcb_has_pid(tAVCT_LCB *p_lcb, UINT16 pid); 159extern BOOLEAN avct_lcb_last_ccb(tAVCT_LCB *p_lcb, tAVCT_CCB *p_ccb_last); 160 161/* LCB action functions */ 162extern void avct_lcb_chnl_open(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 163extern void avct_lcb_unbind_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 164extern void avct_lcb_open_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 165extern void avct_lcb_open_fail(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 166extern void avct_lcb_close_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 167extern void avct_lcb_close_cfm(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 168extern void avct_lcb_bind_conn(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 169extern void avct_lcb_chk_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 170extern void avct_lcb_chnl_disc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 171extern void avct_lcb_bind_fail(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 172extern void avct_lcb_cong_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 173extern void avct_lcb_discard_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 174extern void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 175extern void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 176extern void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data); 177 178/* BCB action functions */ 179#if (AVCT_BROWSE_INCLUDED == TRUE) 180typedef void (*tAVCT_BCB_ACTION)(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 181extern void avct_bcb_chnl_open(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 182extern void avct_bcb_unbind_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 183extern void avct_bcb_open_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 184extern void avct_bcb_open_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 185extern void avct_bcb_close_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 186extern void avct_bcb_close_cfm(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 187extern void avct_bcb_bind_conn(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 188extern void avct_bcb_chk_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 189extern void avct_bcb_chnl_disc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 190extern void avct_bcb_bind_fail(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 191extern void avct_bcb_cong_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 192extern void avct_bcb_discard_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 193extern void avct_bcb_send_msg(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 194extern void avct_bcb_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 195extern void avct_bcb_free_msg_ind(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 196 197extern void avct_bcb_dealloc(tAVCT_BCB *p_bcb, tAVCT_LCB_EVT *p_data); 198 199extern const tAVCT_BCB_ACTION avct_bcb_action[]; 200extern const UINT8 avct_lcb_pkt_type_len[]; 201extern const tL2CAP_FCR_OPTS avct_l2c_br_fcr_opts_def; 202#endif 203 204/* CCB function declarations */ 205extern tAVCT_CCB *avct_ccb_alloc(tAVCT_CC *p_cc); 206extern void avct_ccb_dealloc(tAVCT_CCB *p_ccb, UINT8 event, UINT16 result, BD_ADDR bd_addr); 207extern UINT8 avct_ccb_to_idx(tAVCT_CCB *p_ccb); 208extern tAVCT_CCB *avct_ccb_by_idx(UINT8 idx); 209 210 211/***************************************************************************** 212** global data 213*****************************************************************************/ 214#ifdef __cplusplus 215extern "C" 216{ 217#endif 218 219/* Main control block */ 220#if AVCT_DYNAMIC_MEMORY == FALSE 221AVCT_API extern tAVCT_CB avct_cb; 222#else 223AVCT_API extern tAVCT_CB *avct_cb_ptr; 224#define avct_cb (*avct_cb_ptr) 225#endif 226 227/* L2CAP callback registration structure */ 228extern const tL2CAP_APPL_INFO avct_l2c_appl; 229#if (AVCT_BROWSE_INCLUDED == TRUE) 230extern const tL2CAP_APPL_INFO avct_l2c_br_appl; 231#endif 232 233#ifdef __cplusplus 234} 235#endif 236 237#endif /* AVCT_INT_H */ 238 239 240