avct_int.h 10 KB

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