l2c_int.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 1999-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 L2CAP internal definitions
  21. *
  22. ******************************************************************************/
  23. #ifndef L2C_INT_H
  24. #define L2C_INT_H
  25. #include <stdbool.h>
  26. #include "stack/btm_api.h"
  27. #include "stack/l2c_api.h"
  28. #include "stack/l2cdefs.h"
  29. #include "osi/list.h"
  30. #include "osi/fixed_queue.h"
  31. #define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */
  32. /* LE credit based L2CAP connection parameters */
  33. #define L2CAP_LE_MIN_MTU 23
  34. #define L2CAP_LE_MIN_MPS 23
  35. #define L2CAP_LE_MAX_MPS 65533
  36. #define L2CAP_LE_MIN_CREDIT 0
  37. #define L2CAP_LE_MAX_CREDIT 65535
  38. #define L2CAP_LE_DEFAULT_MTU 512
  39. #define L2CAP_LE_DEFAULT_MPS 23
  40. #define L2CAP_LE_DEFAULT_CREDIT 1
  41. /* Timeouts. Since L2CAP works off a 1-second list, all are in seconds.
  42. */
  43. #define L2CAP_LINK_ROLE_SWITCH_TOUT 10 /* 10 seconds */
  44. #define L2CAP_LINK_CONNECT_TOUT 60 /* 30 seconds */
  45. #define L2CAP_LINK_CONNECT_TOUT_EXT 120 /* 120 seconds */
  46. #define L2CAP_ECHO_RSP_TOUT 30 /* 30 seconds */
  47. #define L2CAP_LINK_FLOW_CONTROL_TOUT 2 /* 2 seconds */
  48. #define L2CAP_LINK_DISCONNECT_TOUT 45 /* 45 seconds */
  49. #ifndef L2CAP_CHNL_CONNECT_TOUT /* BTIF needs to override for internal project needs */
  50. #define L2CAP_CHNL_CONNECT_TOUT 60 /* 60 seconds */
  51. #endif
  52. #define L2CAP_CHNL_CONNECT_TOUT_EXT 120 /* 120 seconds */
  53. #define L2CAP_CHNL_CFG_TIMEOUT 30 /* 30 seconds */
  54. #define L2CAP_CHNL_DISCONNECT_TOUT 10 /* 10 seconds */
  55. #define L2CAP_DELAY_CHECK_SM4 2 /* 2 seconds */
  56. #define L2CAP_WAIT_INFO_RSP_TOUT 3 /* 3 seconds */
  57. #define L2CAP_WAIT_UNPARK_TOUT 2 /* 2 seconds */
  58. #define L2CAP_LINK_INFO_RESP_TOUT 2 /* 2 seconds */
  59. #define L2CAP_UPDATE_CONN_PARAM_TOUT 6 /* 6 seconds */
  60. #define L2CAP_BLE_LINK_CONNECT_TOUT BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT // configed in menuconfig
  61. #define L2CAP_BLE_CONN_PARAM_UPD_TOUT 30 /* 30 seconds */
  62. /* quick timer uses millisecond unit */
  63. #define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
  64. #define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */
  65. #define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */
  66. #define L2CAP_CACHE_ATT_ACL_NUM 10
  67. /* Define the possible L2CAP channel states. The names of
  68. ** the states may seem a bit strange, but they are taken from
  69. ** the Bluetooth specification.
  70. */
  71. typedef enum {
  72. CST_CLOSED, /* Channel is in clodes state */
  73. CST_ORIG_W4_SEC_COMP, /* Originator waits security clearence */
  74. CST_TERM_W4_SEC_COMP, /* Acceptor waits security clearence */
  75. CST_W4_L2CAP_CONNECT_RSP, /* Waiting for peer conenct response */
  76. CST_W4_L2CA_CONNECT_RSP, /* Waiting for upper layer connect rsp */
  77. CST_CONFIG, /* Negotiating configuration */
  78. CST_OPEN, /* Data transfer state */
  79. CST_W4_L2CAP_DISCONNECT_RSP, /* Waiting for peer disconnect rsp */
  80. CST_W4_L2CA_DISCONNECT_RSP /* Waiting for upper layer disc rsp */
  81. } tL2C_CHNL_STATE;
  82. /* Define the possible L2CAP link states
  83. */
  84. typedef enum {
  85. LST_DISCONNECTED,
  86. LST_CONNECT_HOLDING,
  87. LST_CONNECTING_WAIT_SWITCH,
  88. LST_CONNECTING,
  89. LST_CONNECTED,
  90. LST_DISCONNECTING
  91. } tL2C_LINK_STATE;
  92. /* Define input events to the L2CAP link and channel state machines. The names
  93. ** of the events may seem a bit strange, but they are taken from
  94. ** the Bluetooth specification.
  95. */
  96. #define L2CEVT_LP_CONNECT_CFM 0 /* Lower layer connect confirm */
  97. #define L2CEVT_LP_CONNECT_CFM_NEG 1 /* Lower layer connect confirm (failed) */
  98. #define L2CEVT_LP_CONNECT_IND 2 /* Lower layer connect indication */
  99. #define L2CEVT_LP_DISCONNECT_IND 3 /* Lower layer disconnect indication */
  100. #define L2CEVT_LP_QOS_CFM 4 /* Lower layer QOS confirmation */
  101. #define L2CEVT_LP_QOS_CFM_NEG 5 /* Lower layer QOS confirmation (failed)*/
  102. #define L2CEVT_LP_QOS_VIOLATION_IND 6 /* Lower layer QOS violation indication */
  103. #define L2CEVT_SEC_COMP 7 /* Security cleared successfully */
  104. #define L2CEVT_SEC_COMP_NEG 8 /* Security procedure failed */
  105. #define L2CEVT_L2CAP_CONNECT_REQ 10 /* Peer connection request */
  106. #define L2CEVT_L2CAP_CONNECT_RSP 11 /* Peer connection response */
  107. #define L2CEVT_L2CAP_CONNECT_RSP_PND 12 /* Peer connection response pending */
  108. #define L2CEVT_L2CAP_CONNECT_RSP_NEG 13 /* Peer connection response (failed) */
  109. #define L2CEVT_L2CAP_CONFIG_REQ 14 /* Peer configuration request */
  110. #define L2CEVT_L2CAP_CONFIG_RSP 15 /* Peer configuration response */
  111. #define L2CEVT_L2CAP_CONFIG_RSP_NEG 16 /* Peer configuration response (failed) */
  112. #define L2CEVT_L2CAP_DISCONNECT_REQ 17 /* Peer disconnect request */
  113. #define L2CEVT_L2CAP_DISCONNECT_RSP 18 /* Peer disconnect response */
  114. #define L2CEVT_L2CAP_INFO_RSP 19 /* Peer information response */
  115. #define L2CEVT_L2CAP_DATA 20 /* Peer data */
  116. #define L2CEVT_L2CA_CONNECT_REQ 21 /* Upper layer connect request */
  117. #define L2CEVT_L2CA_CONNECT_RSP 22 /* Upper layer connect response */
  118. #define L2CEVT_L2CA_CONNECT_RSP_NEG 23 /* Upper layer connect response (failed)*/
  119. #define L2CEVT_L2CA_CONFIG_REQ 24 /* Upper layer config request */
  120. #define L2CEVT_L2CA_CONFIG_RSP 25 /* Upper layer config response */
  121. #define L2CEVT_L2CA_CONFIG_RSP_NEG 26 /* Upper layer config response (failed) */
  122. #define L2CEVT_L2CA_DISCONNECT_REQ 27 /* Upper layer disconnect request */
  123. #define L2CEVT_L2CA_DISCONNECT_RSP 28 /* Upper layer disconnect response */
  124. #define L2CEVT_L2CA_DATA_READ 29 /* Upper layer data read */
  125. #define L2CEVT_L2CA_DATA_WRITE 30 /* Upper layer data write */
  126. #define L2CEVT_L2CA_FLUSH_REQ 31 /* Upper layer flush */
  127. #define L2CEVT_TIMEOUT 32 /* Timeout */
  128. #define L2CEVT_SEC_RE_SEND_CMD 33 /* btm_sec has enough info to proceed */
  129. #define L2CEVT_ACK_TIMEOUT 34 /* RR delay timeout */
  130. /* Bitmask to skip over Broadcom feature reserved (ID) to avoid sending two
  131. successive ID values, '0' id only or both */
  132. #define L2CAP_ADJ_BRCM_ID 0x1
  133. #define L2CAP_ADJ_ZERO_ID 0x2
  134. #define L2CAP_ADJ_ID 0x3
  135. /* Return values for l2cu_process_peer_cfg_req() */
  136. #define L2CAP_PEER_CFG_UNACCEPTABLE 0
  137. #define L2CAP_PEER_CFG_OK 1
  138. #define L2CAP_PEER_CFG_DISCONNECT 2
  139. /* eL2CAP option constants */
  140. #define L2CAP_MIN_RETRANS_TOUT 2000 /* Min retransmission timeout if no flush timeout or PBF */
  141. #define L2CAP_MIN_MONITOR_TOUT 12000 /* Min monitor timeout if no flush timeout or PBF */
  142. #define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */
  143. #ifndef MIN
  144. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  145. #endif
  146. typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
  147. typedef struct {
  148. UINT8 next_tx_seq; /* Next sequence number to be Tx'ed */
  149. UINT8 last_rx_ack; /* Last sequence number ack'ed by the peer */
  150. UINT8 next_seq_expected; /* Next peer sequence number expected */
  151. UINT8 last_ack_sent; /* Last peer sequence number ack'ed */
  152. UINT8 num_tries; /* Number of retries to send a packet */
  153. UINT8 max_held_acks; /* Max acks we can hold before sending */
  154. BOOLEAN remote_busy; /* TRUE if peer has flowed us off */
  155. BOOLEAN local_busy; /* TRUE if we have flowed off the peer */
  156. BOOLEAN rej_sent; /* Reject was sent */
  157. BOOLEAN srej_sent; /* Selective Reject was sent */
  158. BOOLEAN wait_ack; /* Transmitter is waiting ack (poll sent) */
  159. BOOLEAN rej_after_srej; /* Send a REJ when SREJ clears */
  160. BOOLEAN send_f_rsp; /* We need to send an F-bit response */
  161. UINT16 rx_sdu_len; /* Length of the SDU being received */
  162. BT_HDR *p_rx_sdu; /* Buffer holding the SDU being received */
  163. fixed_queue_t *waiting_for_ack_q; /* Buffers sent and waiting for peer to ack */
  164. fixed_queue_t *srej_rcv_hold_q; /* Buffers rcvd but held pending SREJ rsp */
  165. fixed_queue_t *retrans_q; /* Buffers being retransmitted */
  166. TIMER_LIST_ENT ack_timer; /* Timer delaying RR */
  167. TIMER_LIST_ENT mon_retrans_timer; /* Timer Monitor or Retransmission */
  168. #if (L2CAP_ERTM_STATS == TRUE)
  169. UINT32 connect_tick_count; /* Time channel was established */
  170. UINT32 ertm_pkt_counts[2]; /* Packets sent and received */
  171. UINT32 ertm_byte_counts[2]; /* Bytes sent and received */
  172. UINT32 s_frames_sent[4]; /* S-frames sent (RR, REJ, RNR, SREJ) */
  173. UINT32 s_frames_rcvd[4]; /* S-frames rcvd (RR, REJ, RNR, SREJ) */
  174. UINT32 xmit_window_closed; /* # of times the xmit window was closed */
  175. UINT32 controller_idle; /* # of times less than 2 packets in controller */
  176. /* when the xmit window was closed */
  177. UINT32 pkts_retransmitted; /* # of packets that were retransmitted */
  178. UINT32 retrans_touts; /* # of retransmission timouts */
  179. UINT32 xmit_ack_touts; /* # of xmit ack timouts */
  180. #define L2CAP_ERTM_STATS_NUM_AVG 10
  181. #define L2CAP_ERTM_STATS_AVG_NUM_SAMPLES 100
  182. UINT32 ack_delay_avg_count;
  183. UINT32 ack_delay_avg_index;
  184. UINT32 throughput_start;
  185. UINT32 throughput[L2CAP_ERTM_STATS_NUM_AVG];
  186. UINT32 ack_delay_avg[L2CAP_ERTM_STATS_NUM_AVG];
  187. UINT32 ack_delay_min[L2CAP_ERTM_STATS_NUM_AVG];
  188. UINT32 ack_delay_max[L2CAP_ERTM_STATS_NUM_AVG];
  189. UINT32 ack_q_count_avg[L2CAP_ERTM_STATS_NUM_AVG];
  190. UINT32 ack_q_count_min[L2CAP_ERTM_STATS_NUM_AVG];
  191. UINT32 ack_q_count_max[L2CAP_ERTM_STATS_NUM_AVG];
  192. #endif
  193. } tL2C_FCRB;
  194. /* Define a registration control block. Every application (e.g. RFCOMM, SDP,
  195. ** TCS etc) that registers with L2CAP is assigned one of these.
  196. */
  197. #if (L2CAP_UCD_INCLUDED == TRUE)
  198. #define L2C_UCD_RCB_ID 0x00
  199. #define L2C_UCD_STATE_UNUSED 0x00
  200. #define L2C_UCD_STATE_W4_DATA 0x01
  201. #define L2C_UCD_STATE_W4_RECEPTION 0x02
  202. #define L2C_UCD_STATE_W4_MTU 0x04
  203. typedef struct {
  204. UINT8 state;
  205. tL2CAP_UCD_CB_INFO cb_info;
  206. } tL2C_UCD_REG;
  207. #endif
  208. typedef struct {
  209. BOOLEAN in_use;
  210. UINT16 psm;
  211. UINT16 real_psm; /* This may be a dummy RCB for an o/b connection but */
  212. /* this is the real PSM that we need to connect to */
  213. #if (L2CAP_UCD_INCLUDED == TRUE)
  214. tL2C_UCD_REG ucd;
  215. #endif
  216. tL2CAP_APPL_INFO api;
  217. } tL2C_RCB;
  218. typedef void (tL2CAP_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT transport,
  219. void *p_ref_data, tBTM_STATUS result);
  220. typedef struct
  221. {
  222. UINT16 psm;
  223. tBT_TRANSPORT transport;
  224. BOOLEAN is_originator;
  225. tL2CAP_SEC_CBACK *p_callback;
  226. void *p_ref_data;
  227. }tL2CAP_SEC_DATA;
  228. #ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
  229. #define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 10
  230. #endif
  231. /* Define a channel control block (CCB). There may be many channel control blocks
  232. ** between the same two Bluetooth devices (i.e. on the same link).
  233. ** Each CCB has unique local and remote CIDs. All channel control blocks on
  234. ** the same physical link and are chained together.
  235. */
  236. typedef struct t_l2c_ccb {
  237. BOOLEAN in_use; /* TRUE when in use, FALSE when not */
  238. tL2C_CHNL_STATE chnl_state; /* Channel state */
  239. tL2CAP_LE_CFG_INFO local_conn_cfg; /* Our config for ble conn oriented channel */
  240. tL2CAP_LE_CFG_INFO peer_conn_cfg; /* Peer device config ble conn oriented channel */
  241. struct t_l2c_ccb *p_next_ccb; /* Next CCB in the chain */
  242. struct t_l2c_ccb *p_prev_ccb; /* Previous CCB in the chain */
  243. struct t_l2c_linkcb *p_lcb; /* Link this CCB is assigned to */
  244. UINT16 local_cid; /* Local CID */
  245. UINT16 remote_cid; /* Remote CID */
  246. TIMER_LIST_ENT timer_entry; /* CCB Timer List Entry */
  247. tL2C_RCB *p_rcb; /* Registration CB for this Channel */
  248. bool should_free_rcb; /* True if RCB was allocated on the heap */
  249. #define IB_CFG_DONE 0x01
  250. #define OB_CFG_DONE 0x02
  251. #define RECONFIG_FLAG 0x04 /* True after initial configuration */
  252. #define CFG_DONE_MASK (IB_CFG_DONE | OB_CFG_DONE)
  253. UINT8 config_done; /* Configuration flag word */
  254. UINT8 local_id; /* Transaction ID for local trans */
  255. UINT8 remote_id; /* Transaction ID for local */
  256. #define CCB_FLAG_NO_RETRY 0x01 /* no more retry */
  257. #define CCB_FLAG_SENT_PENDING 0x02 /* already sent pending response */
  258. UINT8 flags;
  259. tL2CAP_CFG_INFO our_cfg; /* Our saved configuration options */
  260. tL2CAP_CH_CFG_BITS peer_cfg_bits; /* Store what peer wants to configure */
  261. tL2CAP_CFG_INFO peer_cfg; /* Peer's saved configuration options */
  262. fixed_queue_t *xmit_hold_q; /* Transmit data hold queue */
  263. BOOLEAN cong_sent; /* Set when congested status sent */
  264. UINT16 buff_quota; /* Buffer quota before sending congestion */
  265. tL2CAP_CHNL_PRIORITY ccb_priority; /* Channel priority */
  266. tL2CAP_CHNL_DATA_RATE tx_data_rate; /* Channel Tx data rate */
  267. tL2CAP_CHNL_DATA_RATE rx_data_rate; /* Channel Rx data rate */
  268. /* Fields used for eL2CAP */
  269. tL2CAP_ERTM_INFO ertm_info;
  270. tL2C_FCRB fcrb;
  271. UINT16 tx_mps; /* TX MPS adjusted based on current controller */
  272. UINT16 max_rx_mtu;
  273. UINT8 fcr_cfg_tries; /* Max number of negotiation attempts */
  274. BOOLEAN peer_cfg_already_rejected; /* If mode rejected once, set to TRUE */
  275. BOOLEAN out_cfg_fcr_present; /* TRUE if cfg response shoulkd include fcr options */
  276. #define L2CAP_CFG_FCS_OUR 0x01 /* Our desired config FCS option */
  277. #define L2CAP_CFG_FCS_PEER 0x02 /* Peer's desired config FCS option */
  278. #define L2CAP_BYPASS_FCS (L2CAP_CFG_FCS_OUR | L2CAP_CFG_FCS_PEER)
  279. UINT8 bypass_fcs;
  280. #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
  281. BOOLEAN is_flushable; /* TRUE if channel is flushable */
  282. #endif
  283. #if (L2CAP_NUM_FIXED_CHNLS > 0) || (L2CAP_UCD_INCLUDED == TRUE)
  284. UINT16 fixed_chnl_idle_tout; /* Idle timeout to use for the fixed channel */
  285. #endif
  286. UINT16 tx_data_len;
  287. } tL2C_CCB;
  288. /***********************************************************************
  289. ** Define a queue of linked CCBs.
  290. */
  291. typedef struct {
  292. tL2C_CCB *p_first_ccb; /* The first channel in this queue */
  293. tL2C_CCB *p_last_ccb; /* The last channel in this queue */
  294. } tL2C_CCB_Q;
  295. #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
  296. /* Round-Robin service for the same priority channels */
  297. #define L2CAP_NUM_CHNL_PRIORITY 3 /* Total number of priority group (high, medium, low)*/
  298. #define L2CAP_CHNL_PRIORITY_WEIGHT 5 /* weight per priority for burst transmission quota */
  299. #define L2CAP_GET_PRIORITY_QUOTA(pri) ((L2CAP_NUM_CHNL_PRIORITY - (pri)) * L2CAP_CHNL_PRIORITY_WEIGHT)
  300. /* CCBs within the same LCB are served in round robin with priority */
  301. /* It will make sure that low priority channel (for example, HF signaling on RFCOMM) */
  302. /* can be sent to headset even if higher priority channel (for example, AV media channel) */
  303. /* is congested. */
  304. typedef struct {
  305. tL2C_CCB *p_serve_ccb; /* current serving ccb within priority group */
  306. tL2C_CCB *p_first_ccb; /* first ccb of priority group */
  307. UINT8 num_ccb; /* number of channels in priority group */
  308. UINT8 quota; /* burst transmission quota */
  309. } tL2C_RR_SERV;
  310. #endif /* (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) */
  311. /* Define a link control block. There is one link control block between
  312. ** this device and any other device (i.e. BD ADDR).
  313. */
  314. typedef struct t_l2c_linkcb {
  315. BOOLEAN in_use; /* TRUE when in use, FALSE when not */
  316. tL2C_LINK_STATE link_state;
  317. BOOLEAN is_aux; /* This variable used for BLE 5.0 or higher version when do auxiliary connection */
  318. TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */
  319. UINT16 handle; /* The handle used with LM */
  320. tL2C_CCB_Q ccb_queue; /* Queue of CCBs on this LCB */
  321. tL2C_CCB *p_pending_ccb; /* ccb of waiting channel during link disconnect */
  322. TIMER_LIST_ENT info_timer_entry; /* Timer entry for info resp timeout evt */
  323. TIMER_LIST_ENT upda_con_timer; /* Timer entry for update connection parametr */
  324. BD_ADDR remote_bd_addr; /* The BD address of the remote */
  325. UINT8 link_role; /* Master or slave */
  326. UINT8 id;
  327. UINT8 cur_echo_id; /* Current id value for echo request */
  328. tL2CA_ECHO_RSP_CB *p_echo_rsp_cb; /* Echo response callback */
  329. UINT16 idle_timeout; /* Idle timeout */
  330. BOOLEAN is_bonding; /* True - link active only for bonding */
  331. UINT16 link_flush_tout; /* Flush timeout used */
  332. UINT16 link_xmit_quota; /* Num outstanding pkts allowed */
  333. UINT16 sent_not_acked; /* Num packets sent but not acked */
  334. BOOLEAN partial_segment_being_sent; /* Set TRUE when a partial segment */
  335. /* is being sent. */
  336. BOOLEAN w4_info_rsp; /* TRUE when info request is active */
  337. UINT8 info_rx_bits; /* set 1 if received info type */
  338. UINT32 peer_ext_fea; /* Peer's extended features mask */
  339. list_t *link_xmit_data_q; /* Link transmit data buffer queue */
  340. UINT8 peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
  341. #if (L2CAP_UCD_INCLUDED == TRUE)
  342. UINT16 ucd_mtu; /* peer MTU on UCD */
  343. fixed_queue_t *ucd_out_sec_pending_q; /* Security pending outgoing UCD packet */
  344. fixed_queue_t *ucd_in_sec_pending_q; /* Security pending incoming UCD packet */
  345. #endif
  346. BT_HDR *p_hcit_rcv_acl; /* Current HCIT ACL buf being rcvd */
  347. UINT16 idle_timeout_sv; /* Save current Idle timeout */
  348. UINT8 acl_priority; /* L2C_PRIORITY_NORMAL or L2C_PRIORITY_HIGH */
  349. tL2CA_NOCP_CB *p_nocp_cb; /* Num Cmpl pkts callback */
  350. #if (L2CAP_NUM_FIXED_CHNLS > 0)
  351. tL2C_CCB *p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
  352. UINT16 disc_reason;
  353. #endif
  354. tBT_TRANSPORT transport;
  355. #if (BLE_INCLUDED == TRUE)
  356. tBLE_ADDR_TYPE open_addr_type; /* be set by open API */
  357. tBLE_ADDR_TYPE ble_addr_type;
  358. UINT16 tx_data_len; /* tx data length used in data length extension */
  359. fixed_queue_t *le_sec_pending_q; /* LE coc channels waiting for security check completion */
  360. UINT8 sec_act;
  361. #define L2C_BLE_CONN_UPDATE_DISABLE 0x1 /* disable update connection parameters */
  362. #define L2C_BLE_NEW_CONN_PARAM 0x2 /* new connection parameter to be set */
  363. #define L2C_BLE_UPDATE_PENDING 0x4 /* waiting for connection update finished */
  364. #define L2C_BLE_NOT_DEFAULT_PARAM 0x8 /* not using default connection parameters */
  365. #define L2C_BLE_UPDATE_PARAM_FULL 0x10 /* update connection parameters full, can not update */
  366. UINT8 conn_update_mask;
  367. /* cache connection parameters that wait to update */
  368. UINT16 waiting_update_conn_min_interval;
  369. UINT16 waiting_update_conn_max_interval;
  370. UINT16 waiting_update_conn_latency;
  371. UINT16 waiting_update_conn_timeout;
  372. /* cache parameters that is being updated */
  373. UINT16 updating_conn_min_interval;
  374. UINT16 updating_conn_max_interval;
  375. bool updating_param_flag;
  376. /* current connection parameters that current connection is using */
  377. UINT16 current_used_conn_interval;
  378. UINT16 current_used_conn_latency;
  379. UINT16 current_used_conn_timeout;
  380. /* connection parameters update order:
  381. waiting_update_conn_xx -> updating_conn_xx -> current_used_conn_xx
  382. */
  383. /* create connection retry count*/
  384. UINT8 retry_create_con;
  385. UINT32 start_time_s;
  386. #endif
  387. #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
  388. /* each priority group is limited burst transmission */
  389. /* round robin service for the same priority channels */
  390. tL2C_RR_SERV rr_serv[L2CAP_NUM_CHNL_PRIORITY];
  391. UINT8 rr_pri; /* current serving priority group */
  392. #endif
  393. } tL2C_LCB;
  394. /* Define the L2CAP control structure
  395. */
  396. typedef struct {
  397. UINT8 l2cap_trace_level;
  398. UINT16 controller_xmit_window; /* Total ACL window for all links */
  399. UINT16 round_robin_quota; /* Round-robin link quota */
  400. UINT16 round_robin_unacked; /* Round-robin unacked */
  401. BOOLEAN check_round_robin; /* Do a round robin check */
  402. BOOLEAN is_cong_cback_context;
  403. list_t *p_lcb_pool; /* Link Control Block pool */
  404. list_t *p_ccb_pool; /* Channel Control Block pool */
  405. tL2C_RCB rcb_pool[MAX_L2CAP_CLIENTS]; /* Registration info pool */
  406. UINT8 desire_role; /* desire to be master/slave when accepting a connection */
  407. BOOLEAN disallow_switch; /* FALSE, to allow switch at create conn */
  408. UINT16 num_lm_acl_bufs; /* # of ACL buffers on controller */
  409. UINT16 idle_timeout; /* Idle timeout */
  410. list_t *rcv_pending_q; /* Recv pending queue */
  411. TIMER_LIST_ENT rcv_hold_tle; /* Timer list entry for rcv hold */
  412. tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */
  413. UINT16 num_links_active; /* Number of links active */
  414. #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
  415. UINT16 non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
  416. /* Otherwise, L2CAP_PKT_START */
  417. BOOLEAN is_flush_active; /* TRUE if an HCI_Enhanced_Flush has been sent */
  418. #endif
  419. #if L2CAP_CONFORMANCE_TESTING == TRUE
  420. UINT32 test_info_resp; /* Conformance testing needs a dynamic response */
  421. #endif
  422. #if (L2CAP_NUM_FIXED_CHNLS > 0)
  423. tL2CAP_FIXED_CHNL_REG fixed_reg[L2CAP_NUM_FIXED_CHNLS]; /* Reg info for fixed channels */
  424. #endif
  425. #if (BLE_INCLUDED == TRUE)
  426. UINT16 num_ble_links_active; /* Number of LE links active */
  427. BOOLEAN is_ble_connecting;
  428. BD_ADDR ble_connecting_bda;
  429. UINT16 controller_le_xmit_window; /* Total ACL window for all links */
  430. tL2C_BLE_FIXED_CHNLS_MASK l2c_ble_fixed_chnls_mask; // LE fixed channels mask
  431. UINT16 num_lm_ble_bufs; /* # of ACL buffers on controller */
  432. UINT16 ble_round_robin_quota; /* Round-robin link quota */
  433. UINT16 ble_round_robin_unacked; /* Round-robin unacked */
  434. BOOLEAN ble_check_round_robin; /* Do a round robin check */
  435. tL2C_RCB ble_rcb_pool[BLE_MAX_L2CAP_CLIENTS]; /* Registration info pool */
  436. #endif
  437. tL2CA_ECHO_DATA_CB *p_echo_data_cb; /* Echo data callback */
  438. #if (defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) && (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE))
  439. UINT16 high_pri_min_xmit_quota; /* Minimum number of ACL credit for high priority link */
  440. #endif /* (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE) */
  441. UINT16 dyn_psm;
  442. } tL2C_CB;
  443. /* Define a structure that contains the information about a connection.
  444. ** This structure is used to pass between functions, and not all the
  445. ** fields will always be filled in.
  446. */
  447. typedef struct {
  448. BD_ADDR bd_addr; /* Remote BD address */
  449. UINT8 status; /* Connection status */
  450. UINT16 psm; /* PSM of the connection */
  451. UINT16 l2cap_result; /* L2CAP result */
  452. UINT16 l2cap_status; /* L2CAP status */
  453. UINT16 remote_cid; /* Remote CID */
  454. } tL2C_CONN_INFO;
  455. typedef void (tL2C_FCR_MGMT_EVT_HDLR) (UINT8, tL2C_CCB *);
  456. /* The offset in a buffer that L2CAP will use when building commands.
  457. */
  458. #define L2CAP_SEND_CMD_OFFSET 0
  459. /* Number of ACL buffers to use for high priority channel
  460. */
  461. #if (!defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) || (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == FALSE))
  462. #define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A (L2CAP_HIGH_PRI_MIN_XMIT_QUOTA)
  463. #else
  464. #define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A (l2cb.high_pri_min_xmit_quota)
  465. #endif
  466. #ifdef __cplusplus
  467. extern "C" {
  468. #endif
  469. /* L2CAP global data
  470. ************************************
  471. */
  472. #if (!defined L2C_DYNAMIC_MEMORY) || (L2C_DYNAMIC_MEMORY == FALSE)
  473. extern tL2C_CB l2cb;
  474. #else
  475. extern tL2C_CB *l2c_cb_ptr;
  476. #define l2cb (*l2c_cb_ptr)
  477. #endif
  478. /* Functions provided by l2c_main.c
  479. ************************************
  480. */
  481. void l2c_init(void);
  482. void l2c_free(void);
  483. extern void l2c_process_timeout (TIMER_LIST_ENT *p_tle);
  484. extern UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flag);
  485. extern void l2c_rcv_acl_data (BT_HDR *p_msg);
  486. extern void l2c_process_held_packets (BOOLEAN timed_out);
  487. /* Functions provided by l2c_utils.c
  488. ************************************
  489. */
  490. extern tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPORT transport);
  491. extern BOOLEAN l2cu_start_post_bond_timer (UINT16 handle);
  492. extern void l2cu_release_lcb (tL2C_LCB *p_lcb);
  493. extern tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport);
  494. extern tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle);
  495. extern uint8_t l2cu_plcb_active_count(void);
  496. extern void l2cu_update_lcb_4_bonding (BD_ADDR p_bd_addr, BOOLEAN is_bonding);
  497. extern UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb);
  498. extern BOOLEAN l2cu_set_acl_priority (BD_ADDR bd_addr, UINT8 priority, BOOLEAN reset_after_rs);
  499. extern void l2cu_enqueue_ccb (tL2C_CCB *p_ccb);
  500. extern void l2cu_dequeue_ccb (tL2C_CCB *p_ccb);
  501. extern void l2cu_change_pri_ccb (tL2C_CCB *p_ccb, tL2CAP_CHNL_PRIORITY priority);
  502. extern tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid);
  503. extern void l2cu_release_ccb (tL2C_CCB *p_ccb);
  504. extern tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid);
  505. extern tL2C_CCB *l2cu_find_free_ccb(void);
  506. extern tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid);
  507. extern void l2cu_adj_id (tL2C_LCB *p_lcb, UINT8 adj_mask);
  508. extern BOOLEAN l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb);
  509. extern void l2cu_send_peer_cmd_reject (tL2C_LCB *p_lcb, UINT16 reason,
  510. UINT8 rem_id, UINT16 p1, UINT16 p2);
  511. extern void l2cu_send_peer_connect_req (tL2C_CCB *p_ccb);
  512. extern void l2cu_send_peer_connect_rsp (tL2C_CCB *p_ccb, UINT16 result, UINT16 status);
  513. extern void l2cu_send_peer_config_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  514. extern void l2cu_send_peer_config_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  515. extern void l2cu_send_peer_config_rej (tL2C_CCB *p_ccb, UINT8 *p_data, UINT16 data_len, UINT16 rej_len);
  516. extern void l2cu_send_peer_disc_req (tL2C_CCB *p_ccb);
  517. extern void l2cu_send_peer_disc_rsp (tL2C_LCB *p_lcb, UINT8 remote_id, UINT16 local_cid, UINT16 remote_cid);
  518. extern void l2cu_send_peer_echo_req (tL2C_LCB *p_lcb, UINT8 *p_data, UINT16 data_len);
  519. extern void l2cu_send_peer_echo_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
  520. extern void l2cu_send_peer_info_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT16 info_type);
  521. extern void l2cu_reject_connection (tL2C_LCB *p_lcb, UINT16 remote_cid, UINT8 rem_id, UINT16 result);
  522. extern void l2cu_send_peer_info_req (tL2C_LCB *p_lcb, UINT16 info_type);
  523. extern void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb);
  524. extern void l2cu_check_channel_congestion (tL2C_CCB *p_ccb);
  525. extern void l2cu_disconnect_chnl (tL2C_CCB *p_ccb);
  526. #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
  527. extern void l2cu_set_non_flushable_pbf(BOOLEAN);
  528. #endif
  529. #if (BLE_INCLUDED == TRUE)
  530. extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
  531. extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
  532. #endif
  533. extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
  534. extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
  535. extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
  536. /* Functions provided by l2c_ucd.c
  537. ************************************
  538. */
  539. #if (L2CAP_UCD_INCLUDED == TRUE)
  540. void l2c_ucd_delete_sec_pending_q(tL2C_LCB *p_lcb);
  541. void l2c_ucd_enqueue_pending_out_sec_q(tL2C_CCB *p_ccb, void *p_data);
  542. BOOLEAN l2c_ucd_check_pending_info_req(tL2C_CCB *p_ccb);
  543. BOOLEAN l2c_ucd_check_pending_out_sec_q(tL2C_CCB *p_ccb);
  544. void l2c_ucd_send_pending_out_sec_q(tL2C_CCB *p_ccb);
  545. void l2c_ucd_discard_pending_out_sec_q(tL2C_CCB *p_ccb);
  546. BOOLEAN l2c_ucd_check_pending_in_sec_q(tL2C_CCB *p_ccb);
  547. void l2c_ucd_send_pending_in_sec_q(tL2C_CCB *p_ccb);
  548. void l2c_ucd_discard_pending_in_sec_q(tL2C_CCB *p_ccb);
  549. BOOLEAN l2c_ucd_check_rx_pkts(tL2C_LCB *p_lcb, BT_HDR *p_msg);
  550. BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data);
  551. #endif
  552. #if (BLE_INCLUDED == TRUE)
  553. extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
  554. extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
  555. extern void l2cu_reject_ble_connection (tL2C_LCB *p_lcb, UINT8 rem_id, UINT16 result);
  556. extern void l2cu_send_peer_ble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
  557. extern void l2cu_send_peer_ble_credit_based_conn_req (tL2C_CCB *p_ccb);
  558. extern void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
  559. extern void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb);
  560. #endif
  561. extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
  562. extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
  563. extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
  564. /* Functions provided for Broadcom Aware
  565. ****************************************
  566. */
  567. extern BOOLEAN l2cu_check_feature_req (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
  568. extern void l2cu_check_feature_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
  569. extern void l2cu_send_feature_req (tL2C_CCB *p_ccb);
  570. extern tL2C_RCB *l2cu_allocate_rcb (UINT16 psm);
  571. extern tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm);
  572. extern void l2cu_release_rcb (tL2C_RCB *p_rcb);
  573. extern tL2C_RCB *l2cu_allocate_ble_rcb (UINT16 psm);
  574. extern tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm);
  575. #if (L2CAP_COC_INCLUDED == TRUE)
  576. extern UINT8 l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  577. extern void l2cu_process_peer_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  578. extern void l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  579. extern void l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  580. #endif // (L2CAP_COC_INCLUDED == TRUE)
  581. extern void l2cu_device_reset (void);
  582. extern tL2C_LCB *l2cu_find_lcb_by_state (tL2C_LINK_STATE state);
  583. extern BOOLEAN l2cu_lcb_disconnecting (void);
  584. extern BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport);
  585. extern BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb);
  586. extern BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb);
  587. extern void l2cu_resubmit_pending_sec_req (BD_ADDR p_bda);
  588. extern void l2cu_initialize_amp_ccb (tL2C_LCB *p_lcb);
  589. extern void l2cu_adjust_out_mps (tL2C_CCB *p_ccb);
  590. /* Functions provided by l2c_link.c
  591. ************************************
  592. */
  593. extern BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr);
  594. extern BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda);
  595. extern BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason);
  596. extern BOOLEAN l2c_link_hci_qos_violation (UINT16 handle);
  597. extern void l2c_link_timeout (tL2C_LCB *p_lcb);
  598. extern void l2c_info_timeout (tL2C_LCB *p_lcb);
  599. extern void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf);
  600. extern void l2c_link_adjust_allocation (void);
  601. extern void l2c_link_process_num_completed_pkts (UINT8 *p);
  602. extern void l2c_link_process_num_completed_blocks (UINT8 controller_id, UINT8 *p, UINT16 evt_len);
  603. extern void l2c_link_processs_num_bufs (UINT16 num_lm_acl_bufs);
  604. extern UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles);
  605. extern void l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status);
  606. extern void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data, UINT8 status);
  607. extern void l2c_link_segments_xmitted (BT_HDR *p_msg);
  608. extern void l2c_pin_code_request (BD_ADDR bd_addr);
  609. extern void l2c_link_adjust_chnl_allocation (void);
  610. #if (BLE_INCLUDED == TRUE)
  611. extern void l2c_link_processs_ble_num_bufs (UINT16 num_lm_acl_bufs);
  612. #endif
  613. #if L2CAP_WAKE_PARKED_LINK == TRUE
  614. extern BOOLEAN l2c_link_check_power_mode ( tL2C_LCB *p_lcb );
  615. #define L2C_LINK_CHECK_POWER_MODE(x) l2c_link_check_power_mode ((x))
  616. #else // L2CAP_WAKE_PARKED_LINK
  617. #define L2C_LINK_CHECK_POWER_MODE(x) (FALSE)
  618. #endif // L2CAP_WAKE_PARKED_LINK
  619. #if L2CAP_CONFORMANCE_TESTING == TRUE
  620. /* Used only for conformance testing */
  621. extern void l2cu_set_info_rsp_mask (UINT32 mask);
  622. #endif
  623. /* Functions provided by l2c_csm.c
  624. ************************************
  625. */
  626. #if (L2CAP_COC_INCLUDED == TRUE)
  627. extern void l2c_csm_execute (tL2C_CCB *p_ccb, UINT16 event, void *p_data);
  628. #endif
  629. extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf);
  630. /* Functions provided by l2c_fcr.c
  631. ************************************
  632. */
  633. extern void l2c_fcr_cleanup (tL2C_CCB *p_ccb);
  634. extern void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf);
  635. extern void l2c_fcr_proc_tout (tL2C_CCB *p_ccb);
  636. extern void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb);
  637. extern void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit);
  638. extern BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes);
  639. extern BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb);
  640. extern BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length);
  641. extern void l2c_fcr_start_timer (tL2C_CCB *p_ccb);
  642. /* Configuration negotiation */
  643. extern UINT8 l2c_fcr_chk_chan_modes (tL2C_CCB *p_ccb);
  644. extern BOOLEAN l2c_fcr_adj_our_req_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  645. extern void l2c_fcr_adj_our_rsp_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_peer_cfg);
  646. extern BOOLEAN l2c_fcr_renegotiate_chan(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  647. extern UINT8 l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
  648. extern void l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb);
  649. extern void l2c_fcr_stop_timer (tL2C_CCB *p_ccb);
  650. extern void l2c_fcr_free_timer (tL2C_CCB *p_ccb);
  651. /* Functions provided by l2c_ble.c
  652. ************************************
  653. */
  654. #if (BLE_INCLUDED == TRUE)
  655. extern BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb);
  656. extern void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len);
  657. extern void l2cble_conn_comp (UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
  658. UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout);
  659. extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
  660. extern void l2cble_notify_le_connection (BD_ADDR bda);
  661. extern void l2c_ble_link_adjust_allocation (void);
  662. extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval,
  663. UINT16 conn_latency, UINT16 conn_timeout);
  664. extern void l2cble_get_conn_param_format_err_from_contoller(UINT8 status, UINT16 handle);
  665. extern void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb);
  666. extern void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
  667. extern void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb);
  668. extern void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
  669. extern BOOLEAN l2ble_sec_access_req(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator, tL2CAP_SEC_CBACK *p_callback, void *p_ref_data);
  670. #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
  671. extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
  672. UINT16 latency, UINT16 timeout);
  673. #endif
  674. extern void l2cble_update_data_length(tL2C_LCB *p_lcb);
  675. extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid,
  676. UINT16 tx_mtu);
  677. extern void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status);
  678. extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
  679. UINT16 rx_data_len);
  680. extern UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb);
  681. #endif
  682. extern void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb);
  683. #ifdef __cplusplus
  684. }
  685. #endif
  686. #endif