1 /******************************************************************************
2  *
3  *  Copyright (C) 1998-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 is the private file for the message access equipment (MSE)
22  *  subsystem.
23  *
24  ******************************************************************************/
25 #ifndef BTA_HL_INT_H
26 #define BTA_HL_INT_H
27 
28 #include "bt_target.h"
29 #include "bta_sys.h"
30 #include "bta_hl_api.h"
31 #include "bta_hl_co.h"
32 #include "l2cdefs.h"
33 
34 
35 typedef UINT16 (tBTA_HL_ALLOCATE_PSM) (void);
36 
37 /*****************************************************************************
38 **  Constants and data types
39 *****************************************************************************/
40 
41 #ifndef BTA_HL_DISC_SIZE
42 #define BTA_HL_DISC_SIZE                1600
43 #endif
44 #define BTA_HL_NUM_SRCH_ATTR            10
45 #define BTA_HL_MIN_SDP_MDEP_LEN         7
46 
47 /* L2CAP defualt parameters */
48 #define BTA_HL_L2C_TX_WIN_SIZE          10
49 #define BTA_HL_L2C_MAX_TRANSMIT         32
50 #define BTA_HL_L2C_RTRANS_TOUT          2000
51 #define BTA_HL_L2C_MON_TOUT             12000
52 #define BTA_HL_L2C_MPS                  1017
53 #define BTA_HL_L2C_USER_RX_POOL_ID      L2CAP_DEFAULT_ERM_POOL_ID
54 #define BTA_HL_L2C_USER_TX_POOL_ID      L2CAP_DEFAULT_ERM_POOL_ID /* todo this should be based on data type */
55 #define BTA_HL_L2C_FCR_RX_POOL_ID       L2CAP_DEFAULT_ERM_POOL_ID
56 #define BTA_HL_L2C_FCR_TX_POOL_ID       L2CAP_DEFAULT_ERM_POOL_ID
57 
58 /* L2CAP FCS setting*/
59 #define BTA_HL_MCA_USE_FCS              MCA_FCS_USE
60 #define BTA_HL_MCA_NO_FCS               MCA_FCS_BYPASS
61 #define BTA_HL_L2C_USE_FCS              1
62 #define BTA_HL_L2C_NO_FCS               0
63 #define BTA_HL_DEFAULT_SOURCE_FCS       BTA_HL_L2C_USE_FCS
64 
65 /* SDP Operations */
66 #define BTA_HL_SDP_OP_NONE                  0
67 #define BTA_HL_SDP_OP_CCH_INIT              1
68 #define BTA_HL_SDP_OP_DCH_OPEN_INIT         2
69 #define BTA_HL_SDP_OP_DCH_RECONNECT_INIT    3
70 #define BTA_HL_SDP_OP_SDP_QUERY_NEW         4
71 #define BTA_HL_SDP_OP_SDP_QUERY_CURRENT     5
72 
73 typedef UINT8 tBTA_HL_SDP_OPER;
74 
75 /* CCH Operations */
76 #define     BTA_HL_CCH_OP_NONE            0
77 #define     BTA_HL_CCH_OP_LOCAL_OPEN      1
78 #define     BTA_HL_CCH_OP_REMOTE_OPEN     2
79 #define     BTA_HL_CCH_OP_LOCAL_CLOSE     3
80 #define     BTA_HL_CCH_OP_REMOTE_CLOSE    4
81 
82 typedef UINT8 tBTA_HL_CCH_OPER;
83 
84 /* Pending DCH close operations when closing a CCH */
85 #define    BTA_HL_CCH_CLOSE_OP_DCH_NONE     0
86 #define    BTA_HL_CCH_CLOSE_OP_DCH_ABORT    1
87 #define    BTA_HL_CCH_CLOSE_OP_DCH_CLOSE    2
88 typedef UINT8 tBTA_HL_CCH_CLOSE_DCH_OPER;
89 
90 /* DCH Operations */
91 #define    BTA_HL_DCH_OP_NONE                    0
92 #define    BTA_HL_DCH_OP_REMOTE_CREATE           1
93 #define    BTA_HL_DCH_OP_LOCAL_OPEN              2
94 #define    BTA_HL_DCH_OP_REMOTE_OPEN             3
95 #define    BTA_HL_DCH_OP_LOCAL_CLOSE             4
96 #define    BTA_HL_DCH_OP_REMOTE_CLOSE            5
97 #define    BTA_HL_DCH_OP_LOCAL_DELETE            6
98 #define    BTA_HL_DCH_OP_REMOTE_DELETE           7
99 #define    BTA_HL_DCH_OP_LOCAL_RECONNECT         8
100 #define    BTA_HL_DCH_OP_REMOTE_RECONNECT        9
101 #define    BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST   10
102 #define    BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT   11
103 
104 typedef UINT8 tBTA_HL_DCH_OPER;
105 
106 /* Echo test Operations */
107 #define    BTA_HL_ECHO_OP_NONE                 0
108 #define    BTA_HL_ECHO_OP_CI_GET_ECHO_DATA     1
109 #define    BTA_HL_ECHO_OP_SDP_INIT             2
110 #define    BTA_HL_ECHO_OP_MDL_CREATE_CFM       3
111 #define    BTA_HL_ECHO_OP_DCH_OPEN_CFM         4
112 #define    BTA_HL_ECHO_OP_LOOP_BACK            5
113 #define    BTA_HL_ECHO_OP_CI_PUT_ECHO_DATA     6
114 #define    BTA_HL_ECHO_OP_DCH_CLOSE_CFM        7
115 #define    BTA_HL_ECHO_OP_OPEN_IND             8
116 #define    BTA_HL_ECHO_OP_ECHO_PKT             9
117 
118 typedef UINT8 tBTA_HL_ECHO_OPER;
119 
120 /* abort status mask for abort_oper */
121 
122 #define BTA_HL_ABORT_NONE_MASK      0x00
123 #define BTA_HL_ABORT_PENDING_MASK   0x01
124 #define BTA_HL_ABORT_LOCAL_MASK     0x10
125 #define BTA_HL_ABORT_REMOTE_MASK    0x20
126 #define BTA_HL_ABORT_CCH_CLOSE_MASK 0x40
127 
128 /* call out mask for cout_oper */
129 #define BTA_HL_CO_NONE_MASK          0x00
130 #define BTA_HL_CO_GET_TX_DATA_MASK   0x01
131 #define BTA_HL_CO_PUT_RX_DATA_MASK   0x02
132 #define BTA_HL_CO_GET_ECHO_DATA_MASK 0x04
133 #define BTA_HL_CO_PUT_ECHO_DATA_MASK 0x08
134 
135 typedef struct
136 {
137     UINT16      mtu;
138     UINT8       fcs;                    /* '0' No FCS, otherwise '1' */
139 } tBTA_HL_L2CAP_CFG_INFO;
140 
141 
142 /* State Machine Events */
143 enum
144 {
145     /* these events are handled by the state machine */
146     BTA_HL_CCH_OPEN_EVT     = BTA_SYS_EVT_START(BTA_ID_HL),
147     BTA_HL_CCH_SDP_OK_EVT,
148     BTA_HL_CCH_SDP_FAIL_EVT,
149     BTA_HL_MCA_CONNECT_IND_EVT,
150     BTA_HL_MCA_DISCONNECT_IND_EVT,
151     BTA_HL_CCH_CLOSE_EVT,
152     BTA_HL_CCH_CLOSE_CMPL_EVT,
153     BTA_HL_MCA_RSP_TOUT_IND_EVT,
154     /* DCH EVENT */
155     BTA_HL_DCH_SDP_INIT_EVT,
156     BTA_HL_DCH_OPEN_EVT,
157     BTA_HL_MCA_CREATE_IND_EVT,
158     BTA_HL_MCA_CREATE_CFM_EVT,
159     BTA_HL_MCA_OPEN_IND_EVT,
160 
161     BTA_HL_MCA_OPEN_CFM_EVT,
162     BTA_HL_DCH_CLOSE_EVT,
163     BTA_HL_MCA_CLOSE_IND_EVT,
164     BTA_HL_MCA_CLOSE_CFM_EVT,
165     BTA_HL_API_SEND_DATA_EVT,
166 
167     BTA_HL_MCA_RCV_DATA_EVT,
168     BTA_HL_DCH_CLOSE_CMPL_EVT,
169     BTA_HL_DCH_RECONNECT_EVT,
170     BTA_HL_DCH_SDP_FAIL_EVT,
171     BTA_HL_MCA_RECONNECT_IND_EVT,
172 
173     BTA_HL_MCA_RECONNECT_CFM_EVT,
174     BTA_HL_DCH_CLOSE_ECHO_TEST_EVT,
175     BTA_HL_API_DCH_CREATE_RSP_EVT,
176     BTA_HL_DCH_ABORT_EVT,
177     BTA_HL_MCA_ABORT_IND_EVT,
178 
179     BTA_HL_MCA_ABORT_CFM_EVT,
180     BTA_HL_MCA_CONG_CHG_EVT,
181     BTA_HL_CI_GET_TX_DATA_EVT,
182     BTA_HL_CI_PUT_RX_DATA_EVT,
183     BTA_HL_CI_GET_ECHO_DATA_EVT,
184     BTA_HL_DCH_ECHO_TEST_EVT,
185     BTA_HL_CI_PUT_ECHO_DATA_EVT,
186 
187     /* these events are handled outside the state machine */
188     BTA_HL_API_ENABLE_EVT,
189     BTA_HL_API_DISABLE_EVT,
190     BTA_HL_API_UPDATE_EVT,
191     BTA_HL_API_REGISTER_EVT,
192     BTA_HL_API_DEREGISTER_EVT,
193     BTA_HL_API_CCH_OPEN_EVT,
194     BTA_HL_API_CCH_CLOSE_EVT,
195     BTA_HL_API_DCH_OPEN_EVT,
196     BTA_HL_API_DCH_RECONNECT_EVT,
197     BTA_HL_API_DCH_CLOSE_EVT,
198     BTA_HL_API_DELETE_MDL_EVT,
199     BTA_HL_API_DCH_ABORT_EVT,
200 
201     BTA_HL_API_DCH_ECHO_TEST_EVT,
202     BTA_HL_API_SDP_QUERY_EVT,
203     BTA_HL_SDP_QUERY_OK_EVT,
204     BTA_HL_SDP_QUERY_FAIL_EVT,
205     BTA_HL_MCA_DELETE_IND_EVT,
206     BTA_HL_MCA_DELETE_CFM_EVT
207 };
208 typedef UINT16 tBTA_HL_INT_EVT;
209 
210 #define BTA_HL_DCH_EVT_MIN BTA_HL_DCH_SDP_INIT_EVT
211 #define BTA_HL_DCH_EVT_MAX 0xFFFF
212 
213 
214 /* state machine states */
215 enum
216 {
217     BTA_HL_CCH_IDLE_ST = 0,      /* Idle  */
218     BTA_HL_CCH_OPENING_ST,       /* Opening a connection*/
219     BTA_HL_CCH_OPEN_ST,          /* Connection is open */
220     BTA_HL_CCH_CLOSING_ST        /* Closing is in progress */
221 };
222 typedef UINT8 tBTA_HL_CCH_STATE;
223 
224 enum
225 {
226     BTA_HL_DCH_IDLE_ST = 0,      /* Idle  */
227     BTA_HL_DCH_OPENING_ST,       /* Opening a connection*/
228     BTA_HL_DCH_OPEN_ST,          /* Connection is open */
229     BTA_HL_DCH_CLOSING_ST        /* Closing is in progress */
230 };
231 typedef UINT8 tBTA_HL_DCH_STATE;
232 
233 
234 typedef struct
235 {
236     BT_HDR              hdr;
237     tBTA_HL_CTRL_CBACK  *p_cback;        /* pointer to control callback function */
238 } tBTA_HL_API_ENABLE;
239 
240 typedef struct
241 {
242     BT_HDR              hdr;
243     UINT8               app_id;
244     BOOLEAN             is_register;        /* Update HL application due to register or deregister */
245     tBTA_HL_CBACK       *p_cback;           /* pointer to application callback function */
246     tBTA_HL_DEVICE_TYPE dev_type;           /* sink, source or dual roles */
247     tBTA_SEC            sec_mask;           /* security mask for accepting conenction*/
248     char                srv_name[BTA_SERVICE_NAME_LEN +1];        /* service name to be used in the SDP; null terminated*/
249     char                srv_desp[BTA_SERVICE_DESP_LEN +1];        /* service description to be used in the SDP; null terminated */
250     char                provider_name[BTA_PROVIDER_NAME_LEN +1];   /* provide name to be used in the SDP; null terminated */
251 
252 } tBTA_HL_API_UPDATE;
253 
254 typedef struct
255 {
256     BT_HDR              hdr;
257     UINT8               app_id;
258     tBTA_HL_CBACK       *p_cback;        /* pointer to application callback function */
259     tBTA_HL_DEVICE_TYPE dev_type;           /* sink, source or dual roles */
260     tBTA_SEC            sec_mask;           /* security mask for accepting conenction*/
261     char                srv_name[BTA_SERVICE_NAME_LEN +1];        /* service name to be used in the SDP; null terminated*/
262     char                srv_desp[BTA_SERVICE_DESP_LEN +1];        /* service description to be used in the SDP; null terminated */
263     char                provider_name[BTA_PROVIDER_NAME_LEN +1];   /* provide name to be used in the SDP; null terminated */
264 } tBTA_HL_API_REGISTER;
265 
266 typedef struct
267 {
268     BT_HDR                  hdr;
269     UINT8                   app_id;
270     tBTA_HL_CBACK           *p_cback;        /* pointer to application callback function */
271     tBTA_HL_APP_HANDLE      app_handle;
272 } tBTA_HL_API_DEREGISTER;
273 
274 typedef struct
275 {
276     BT_HDR                  hdr;
277     UINT8                   app_id;
278     tBTA_HL_APP_HANDLE      app_handle;
279     UINT16                  ctrl_psm;
280     BD_ADDR                 bd_addr;        /* Address of peer device */
281     tBTA_SEC                sec_mask;       /* security mask for initiating connection*/
282 } tBTA_HL_API_CCH_OPEN;
283 
284 
285 typedef struct
286 {
287     BT_HDR                  hdr;
288     tBTA_HL_MCL_HANDLE      mcl_handle;
289 } tBTA_HL_API_CCH_CLOSE;
290 
291 
292 
293 typedef struct
294 {
295     BT_HDR                  hdr;
296     tBTA_HL_MCL_HANDLE      mcl_handle;
297     UINT16                  ctrl_psm;
298     tBTA_HL_MDEP_ID         local_mdep_id;     /* local MDEP ID */
299     tBTA_HL_MDEP_ID         peer_mdep_id;      /* peer mdep id */
300     tBTA_HL_DCH_CFG         local_cfg;
301     tBTA_SEC                sec_mask;          /* security mask for initiating connection*/
302 } tBTA_HL_API_DCH_OPEN;
303 
304 
305 typedef struct
306 {
307     BT_HDR                  hdr;
308 
309     tBTA_HL_MCL_HANDLE      mcl_handle;
310     UINT16                  ctrl_psm;
311     tBTA_HL_MDL_ID          mdl_id;
312 } tBTA_HL_API_DCH_RECONNECT;
313 
314 typedef struct
315 {
316     BT_HDR                  hdr;
317     tBTA_HL_MDL_HANDLE      mdl_handle;
318 } tBTA_HL_API_DCH_CLOSE;
319 
320 typedef struct
321 {
322     BT_HDR                  hdr;
323     tBTA_HL_MCL_HANDLE      mcl_handle;
324     tBTA_HL_MDL_ID          mdl_id;
325 } tBTA_HL_API_DELETE_MDL;
326 
327 typedef struct
328 {
329     BT_HDR              hdr;
330     tBTA_HL_MCL_HANDLE mcl_handle;
331 } tBTA_HL_API_DCH_ABORT;
332 
333 
334 typedef struct
335 {
336     BT_HDR              hdr;
337     tBTA_HL_MDL_HANDLE  mdl_handle;
338     UINT16              pkt_size;
339 } tBTA_HL_API_SEND_DATA;
340 
341 typedef struct
342 {
343     BT_HDR              hdr;
344     tBTA_HL_MCL_HANDLE  mcl_handle;
345     UINT16              ctrl_psm;
346     UINT16              pkt_size;
347     tBTA_HL_DCH_CFG     local_cfg;
348 } tBTA_HL_API_DCH_ECHO_TEST;
349 
350 typedef struct
351 {
352     BT_HDR                  hdr;
353     UINT8                   app_idx;
354     UINT8                   mcl_idx;
355     BOOLEAN                 release_mcl_cb;
356 }tBTA_HL_CCH_SDP;
357 
358 
359 /* MCA callback event parameters. */
360 typedef struct
361 {
362     BT_HDR              hdr;
363     tBTA_HL_APP_HANDLE  app_handle;
364     tBTA_HL_MCL_HANDLE  mcl_handle;
365     tMCA_CTRL       mca_data;
366 } tBTA_HL_MCA_EVT;
367 
368 
369 /* MCA callback event parameters. */
370 typedef struct
371 {
372     BT_HDR          hdr;
373     UINT8           app_idx;
374     UINT8           mcl_idx;
375     UINT8           mdl_idx;
376     BT_HDR          *p_pkt;
377 } tBTA_HL_MCA_RCV_DATA_EVT;
378 
379 
380 typedef struct
381 {
382     BT_HDR                  hdr;
383     UINT8                   app_idx;
384     UINT8                   mcl_idx;
385     UINT8                   mdl_idx;
386 }tBTA_HL_DCH_SDP;
387 
388 typedef struct
389 {
390     BT_HDR                  hdr;
391     tBTA_HL_APP_HANDLE      app_handle;
392     UINT8                   app_id;
393     BD_ADDR                 bd_addr;        /* Address of peer device */
394 } tBTA_HL_API_SDP_QUERY;
395 
396 typedef struct
397 {
398     BT_HDR                  hdr;
399     tBTA_HL_MCL_HANDLE      mcl_handle;
400     tBTA_HL_MDL_ID          mdl_id;
401     tBTA_HL_MDEP_ID         local_mdep_id;
402     tBTA_HL_DCH_CREATE_RSP  rsp_code;
403     tBTA_HL_DCH_CFG         cfg_rsp;
404 } tBTA_HL_API_DCH_CREATE_RSP;
405 
406 typedef struct
407 {
408     BT_HDR                  hdr;
409     tBTA_HL_MDL_HANDLE      mdl_handle;
410     tBTA_HL_STATUS          status;
411 } tBTA_HL_CI_GET_PUT_DATA;
412 
413 typedef struct
414 {
415     BT_HDR                  hdr;
416     tBTA_HL_MCL_HANDLE      mcl_handle;
417     tBTA_HL_STATUS          status;
418 } tBTA_HL_CI_ECHO_DATA;
419 
420 /* union of all state machine event data types */
421 typedef union
422 {
423     BT_HDR                      hdr;
424     tBTA_HL_API_ENABLE          api_enable; /* data for BTA_MSE_API_ENABLE_EVT */
425     tBTA_HL_API_UPDATE          api_update;
426     tBTA_HL_API_REGISTER        api_reg;
427     tBTA_HL_API_DEREGISTER      api_dereg;
428     tBTA_HL_API_CCH_OPEN        api_cch_open;
429     tBTA_HL_API_CCH_CLOSE       api_cch_close;
430     tBTA_HL_API_DCH_CREATE_RSP  api_dch_create_rsp;
431     tBTA_HL_API_DCH_OPEN        api_dch_open;
432     tBTA_HL_API_DCH_RECONNECT   api_dch_reconnect;
433     tBTA_HL_API_DCH_CLOSE       api_dch_close;
434     tBTA_HL_API_DELETE_MDL      api_delete_mdl;
435     tBTA_HL_API_DCH_ABORT       api_dch_abort;
436     tBTA_HL_API_SEND_DATA       api_send_data;
437     tBTA_HL_API_DCH_ECHO_TEST   api_dch_echo_test;
438     tBTA_HL_API_SDP_QUERY       api_sdp_query;
439 
440     tBTA_HL_CCH_SDP             cch_sdp;
441     tBTA_HL_MCA_EVT             mca_evt;
442     tBTA_HL_MCA_RCV_DATA_EVT    mca_rcv_data_evt;
443     tBTA_HL_DCH_SDP             dch_sdp; /* for DCH_OPEN_EVT and DCH_RECONNECT_EVT */
444     tBTA_HL_CI_GET_PUT_DATA     ci_get_put_data;
445     tBTA_HL_CI_ECHO_DATA        ci_get_put_echo_data;
446 } tBTA_HL_DATA;
447 
448 
449 typedef struct
450 {
451     BOOLEAN                 in_use;
452     UINT16                  mdl_id;
453     tBTA_HL_MDL_HANDLE      mdl_handle;
454     tBTA_HL_DCH_OPER        dch_oper;
455     BOOLEAN                 intentional_close;
456     tBTA_HL_DCH_STATE       dch_state;
457     UINT8                   abort_oper;
458     UINT16                  req_data_psm;
459     UINT16                  max_rx_apdu_size;
460     UINT16                  max_tx_apdu_size;
461     BT_HDR                  *p_tx_pkt;
462     BT_HDR                  *p_rx_pkt;
463     tBTA_HL_MDEP_ID         local_mdep_id;
464     UINT8                   local_mdep_cfg_idx;
465     tBTA_HL_DCH_CFG         local_cfg;
466     tBTA_HL_DCH_CFG         remote_cfg;
467     tBTA_HL_MDEP_ID         peer_mdep_id;
468     UINT16  peer_data_type;
469     tBTA_HL_MDEP_ROLE       peer_mdep_role;
470     tBTA_HL_DCH_MODE        dch_mode;
471     tBTA_SEC                sec_mask;
472     BOOLEAN                 is_the_first_reliable;
473     BOOLEAN                 delete_mdl;
474     UINT16                  mtu;
475     tMCA_CHNL_CFG           chnl_cfg;
476     BOOLEAN                 mdl_cfg_idx_included;
477     UINT8                   mdl_cfg_idx;
478     UINT8                   echo_oper;
479     BOOLEAN                 cong;
480     BOOLEAN                 close_pending;
481     UINT8                   cout_oper;
482     BT_HDR                  *p_echo_tx_pkt;
483     BT_HDR                  *p_echo_rx_pkt;
484     tBTA_HL_STATUS          ci_put_echo_data_status;
485 }tBTA_HL_MDL_CB;
486 
487 typedef struct
488 {
489     tBTA_HL_MDL_CB          mdl[BTA_HL_NUM_MDLS_PER_MCL];
490     tBTA_HL_DELETE_MDL      delete_mdl;
491     BOOLEAN                 in_use;
492     tBTA_HL_CCH_STATE       cch_state;
493     UINT16                  req_ctrl_psm;
494     UINT16                  ctrl_psm;
495     UINT16                  data_psm;
496     BD_ADDR                 bd_addr;
497     UINT16                  cch_mtu;
498     UINT16                  sec_mask;
499     tBTA_HL_MCL_HANDLE      mcl_handle;
500     tSDP_DISCOVERY_DB       *p_db;         /* pointer to discovery database */
501     tSDP_DISC_CMPL_CB       *sdp_cback;
502     tBTA_HL_SDP_OPER        sdp_oper;
503     BOOLEAN                 close_pending;
504     UINT8                   sdp_mdl_idx;
505     tBTA_HL_SDP             sdp;
506     UINT8                   cch_oper;
507     UINT8                   force_close_local_cch_opening;
508     BOOLEAN                 intentional_close;
509     BOOLEAN                 rsp_tout;
510     UINT8                   timer_oper;
511     BOOLEAN                 echo_test;
512     UINT8                   echo_mdl_idx;
513     UINT8                   cch_close_dch_oper;
514     UINT8                   app_id;
515 }tBTA_HL_MCL_CB;
516 
517 typedef struct
518 {
519     tBTA_HL_MCL_CB       mcb[BTA_HL_NUM_MCLS]; /* application Control Blocks */
520     tBTA_HL_CBACK        *p_cback;            /* pointer to control callback function */
521     BOOLEAN              in_use;              /* this CB is in use*/
522     BOOLEAN              deregistering;
523     UINT8                app_id;
524     UINT32               sdp_handle;    /* SDP record handle */
525     tBTA_HL_SUP_FEATURE  sup_feature;
526     tBTA_HL_MDL_CFG      mdl_cfg[BTA_HL_NUM_MDL_CFGS];
527     tBTA_HL_DEVICE_TYPE  dev_type;
528     tBTA_HL_APP_HANDLE   app_handle;
529     UINT16               ctrl_psm;   /* L2CAP PSM for the MCAP control channel */
530     UINT16               data_psm;   /* L2CAP PSM for the MCAP data channel */
531     UINT16               sec_mask;   /* Security mask for BTM_SetSecurityLevel() */
532 
533     char                 srv_name[BTA_SERVICE_NAME_LEN +1];        /* service name to be used in the SDP; null terminated*/
534     char                 srv_desp[BTA_SERVICE_DESP_LEN +1];        /* service description to be used in the SDP; null terminated */
535     char                 provider_name[BTA_PROVIDER_NAME_LEN +1];   /* provide name to be used in the SDP; null terminated */
536 
537     tMCA_CTRL_CBACK      *p_mcap_cback;            /* pointer to MCAP callback function */
538     tMCA_DATA_CBACK      *p_data_cback;
539 }tBTA_HL_APP_CB;
540 
541 
542 typedef struct
543 {
544     BOOLEAN             in_use;
545     tBTA_HL_SDP_OPER    sdp_oper;
546     UINT8               app_idx;
547     UINT8               mcl_idx;
548     UINT8               mdl_idx;
549 }tBTA_HL_SDP_CB;
550 
551 typedef struct
552 {
553     BOOLEAN         in_use;
554     UINT8           app_idx;
555     UINT8           mcl_idx;
556 }tBTA_HL_TIMER_CB;
557 
558 typedef struct
559 {
560     tBTA_HL_APP_CB        acb[BTA_HL_NUM_APPS];      /* HL Control Blocks */
561     tBTA_HL_CTRL_CBACK    *p_ctrl_cback;            /* pointer to control callback function */
562     BOOLEAN               enable;
563     BOOLEAN               disabling;
564 
565     tBTA_HL_SDP_CB        scb[BTA_HL_NUM_SDP_CBACKS];
566     tBTA_HL_TIMER_CB      tcb[BTA_HL_NUM_TIMERS];
567     BOOLEAN               enable_random_psm;
568     tBTA_HL_ALLOCATE_PSM  *p_alloc_psm;
569 }tBTA_HL_CB;
570 
571 /******************************************************************************
572 **  Configuration Definitions
573 *******************************************************************************/
574 /* Configuration structure */
575 
576 /*****************************************************************************
577 **  Global data
578 *****************************************************************************/
579 
580 /* HL control block */
581 #if BTA_DYNAMIC_MEMORY == FALSE
582 extern tBTA_HL_CB  bta_hl_cb;
583 #else
584 extern tBTA_HL_CB *bta_hl_cb_ptr;
585     #define bta_hl_cb (*bta_hl_cb_ptr)
586 #endif
587 
588 #define BTA_HL_GET_CB_PTR() &(bta_hl_cb)
589 #define BTA_HL_GET_APP_CB_PTR(app_idx) &(bta_hl_cb.acb[(app_idx)])
590 #define BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx) &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)])
591 #define BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx) &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)].mdl[mdl_idx])
592 #define BTA_HL_GET_MDL_CFG_PTR(app_idx, item_idx) &(bta_hl_cb.acb[(app_idx)].mdl_cfg[(item_idx)])
593 #define BTA_HL_GET_ECHO_CFG_PTR(app_idx)  &(bta_hl_cb.acb[(app_idx)].sup_feature.echo_cfg)
594 #define BTA_HL_GET_MDEP_CFG_PTR(app_idx, mdep_cfg_idx)  &(bta_hl_cb.acb[(app_idx)].sup_feature.mdep[mdep_cfg_idx].mdep_cfg)
595 #define BTA_HL_GET_DATA_CFG_PTR(app_idx, mdep_cfg_idx, data_cfg_idx)  \
596            &(bta_hl_cb.acb[(app_idx)].sup_feature.mdep[mdep_cfg_idx].mdep_cfg.data_cfg[data_cfg_idx])
597 #define BTA_HL_GET_BUF_PTR(p_pkt) ((UINT8 *)((UINT8 *) (p_pkt+1) + p_pkt->offset))
598 
599 /*****************************************************************************
600 **  Function prototypes
601 *****************************************************************************/
602 
603 #ifdef __cplusplus
604 extern "C"
605 {
606 #endif
607     /* main */
608     extern BOOLEAN bta_hl_hdl_event(BT_HDR *p_msg);
609     /* sdp */
610     extern BOOLEAN bta_hl_fill_sup_feature_list( const tSDP_DISC_ATTR  *p_attr,
611                                                  tBTA_HL_SUP_FEATURE_LIST_ELEM *p_list);
612     extern tBTA_HL_STATUS bta_hl_sdp_update (UINT8 app_id);
613     extern tBTA_HL_STATUS bta_hl_sdp_register (UINT8 app_idx);
614     extern tSDP_DISC_REC *bta_hl_find_sink_or_src_srv_class_in_db (const tSDP_DISCOVERY_DB *p_db,
615                                                                    const tSDP_DISC_REC *p_start_rec);
616 
617     /* action routines */
618     extern void bta_hl_dch_ci_get_tx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
619                                           tBTA_HL_DATA *p_data);
620     extern void bta_hl_dch_ci_put_rx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
621                                           tBTA_HL_DATA *p_data);
622     extern void bta_hl_dch_ci_get_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
623                                             tBTA_HL_DATA *p_data);
624 
625     extern void bta_hl_dch_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
626                                      tBTA_HL_DATA *p_data);
627     extern void bta_hl_dch_ci_put_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
628                                             tBTA_HL_DATA *p_data);
629     extern void bta_hl_dch_send_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
630                                      tBTA_HL_DATA *p_data);
631     extern void bta_hl_dch_sdp_fail(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
632                                     tBTA_HL_DATA *p_data);
633     extern void bta_hl_dch_mca_cong_change(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
634                                            tBTA_HL_DATA *p_data);
635     extern void bta_hl_dch_mca_reconnect_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
636                                              tBTA_HL_DATA *p_data);
637     extern void bta_hl_dch_mca_reconnect_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
638                                              tBTA_HL_DATA *p_data);
639     extern void bta_hl_dch_mca_reconnect(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
640                                          tBTA_HL_DATA *p_data);
641     extern void bta_hl_dch_sdp_init(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
642                                     tBTA_HL_DATA *p_data);
643     extern void bta_hl_dch_close_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
644                                            tBTA_HL_DATA *p_data);
645     extern void bta_hl_dch_create_rsp(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
646                                       tBTA_HL_DATA *p_data);
647     extern void bta_hl_dch_mca_rcv_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
648                                         tBTA_HL_DATA *p_data);
649     extern void bta_hl_dch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
650                                       tBTA_HL_DATA *p_data);
651     extern void bta_hl_dch_mca_close_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
652                                          tBTA_HL_DATA *p_data);
653     extern void bta_hl_dch_mca_close_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
654                                          tBTA_HL_DATA *p_data);
655     extern void bta_hl_dch_mca_close(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
656                                      tBTA_HL_DATA *p_data);
657     extern void bta_hl_dch_mca_delete_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
658                                           tBTA_HL_DATA *p_data);
659 
660     extern void bta_hl_dch_mca_delete_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
661                                           tBTA_HL_DATA *p_data);
662     extern void bta_hl_dch_mca_delete(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
663                                       tBTA_HL_DATA *p_data);
664     extern void bta_hl_dch_mca_abort_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
665                                          tBTA_HL_DATA *p_data);
666     extern void bta_hl_dch_mca_abort_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
667                                          tBTA_HL_DATA *p_data);
668     extern void bta_hl_dch_mca_abort(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
669                                      tBTA_HL_DATA *p_data);
670     extern void bta_hl_dch_mca_open_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
671                                         tBTA_HL_DATA *p_data);
672     extern void bta_hl_dch_mca_open_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
673                                         tBTA_HL_DATA *p_data);
674     extern void bta_hl_dch_mca_create_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
675                                           tBTA_HL_DATA *p_data);
676     extern void bta_hl_dch_mca_create_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
677                                           tBTA_HL_DATA *p_data);
678     extern void bta_hl_dch_mca_create(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
679                                       tBTA_HL_DATA *p_data);
680     extern void bta_hl_deallocate_spd_cback(UINT8 sdp_cback_idx);
681     extern tSDP_DISC_CMPL_CB *bta_hl_allocate_spd_cback(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
682                                                         UINT8 mdl_idx,
683                                                         UINT8 *p_sdp_cback_idx);
684     extern tBTA_HL_STATUS bta_hl_init_sdp(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
685                                           UINT8 mdl_idx);
686     extern void bta_hl_cch_sdp_init(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
687     extern void bta_hl_cch_mca_open(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
688     extern void bta_hl_cch_mca_close(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
689     extern void bta_hl_cch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
690     extern void bta_hl_cch_mca_disconnect(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
691     extern void bta_hl_cch_mca_disc_open(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
692     extern void bta_hl_cch_mca_rsp_tout(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
693     extern void bta_hl_cch_mca_connect(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data);
694 
695     /* State machine drivers  */
696     extern void bta_hl_cch_sm_execute(UINT8 inst_idx, UINT8 mcl_idx,
697                                       UINT16 event, tBTA_HL_DATA *p_data);
698     extern void bta_hl_dch_sm_execute(UINT8 inst_idx, UINT8 mcl_idx, UINT8 mdl_idx,
699                                       UINT16 event, tBTA_HL_DATA *p_data);
700     /* MCAP callback functions  */
701     extern void bta_hl_mcap_ctrl_cback(tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event,
702                                        tMCA_CTRL *p_data);
703 
704     extern void bta_hl_mcap_data_cback(tMCA_DL mdl, BT_HDR *p_pkt);
705 
706     /* utility functions  */
707     extern BOOLEAN bta_hl_set_ctrl_psm_for_dch(UINT8 app_idx, UINT8 mcl_idx,
708                                                UINT8 mdl_idx, UINT16 ctrl_psm);
709     extern BOOLEAN bta_hl_find_sdp_idx_using_ctrl_psm(tBTA_HL_SDP *p_sdp,
710                                                       UINT16 ctrl_psm,
711                                                       UINT8 *p_sdp_idx);
712     extern UINT8 bta_hl_set_user_tx_pool_id(UINT16 max_tx_size);
713     extern UINT8 bta_hl_set_user_rx_pool_id(UINT16 mtu);
714     extern UINT8 bta_hl_set_tx_win_size(UINT16 mtu, UINT16 mps);
715     extern UINT16 bta_hl_set_mps(UINT16 mtu);
716     extern void bta_hl_clean_mdl_cb(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx);
717     extern BT_HDR * bta_hl_get_buf(UINT16 data_size);
718     extern BOOLEAN bta_hl_find_service_in_db( UINT8 app_idx, UINT8 mcl_idx,
719                                               UINT16 service_uuid,
720                                               tSDP_DISC_REC **pp_rec );
721     extern UINT16 bta_hl_get_service_uuids(UINT8 sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
722                                            UINT8 mdl_idx );
723     extern BOOLEAN bta_hl_find_echo_cfg_rsp(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdep_idx, UINT8 cfg,
724                                             UINT8 *p_cfg_rsp);
725     extern BOOLEAN bta_hl_validate_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
726                                        UINT8 cfg);
727     extern BOOLEAN bta_hl_find_cch_cb_indexes(tBTA_HL_DATA *p_msg,
728                                               UINT8 *p_app_idx,
729                                               UINT8  *p_mcl_idx);
730     extern BOOLEAN bta_hl_find_dch_cb_indexes(tBTA_HL_DATA *p_msg,
731                                               UINT8 *p_app_idx,
732                                               UINT8 *p_mcl_idx,
733                                               UINT8 *p_mdl_idx);
734     extern UINT16  bta_hl_allocate_mdl_id(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx );
735     extern BOOLEAN bta_hl_find_mdl_idx_using_handle(tBTA_HL_MDL_HANDLE mdl_handle,
736                                                     UINT8 *p_app_idx, UINT8 *p_mcl_idx,
737                                                     UINT8 *p_mdl_idx);
738     extern BOOLEAN bta_hl_find_mdl_idx(UINT8 app_idx, UINT8 mcl_idx, UINT16 mdl_id,
739                                        UINT8 *p_mdl_idx);
740     extern BOOLEAN bta_hl_find_an_active_mdl_idx(UINT8 app_idx, UINT8 mcl_idx,
741                                                  UINT8 *p_mdl_idx);
742     extern BOOLEAN bta_hl_find_dch_setup_mdl_idx(UINT8 app_idx, UINT8 mcl_idx,
743                                                  UINT8 *p_mdl_idx);
744     extern BOOLEAN bta_hl_find_an_in_use_mcl_idx(UINT8 app_idx,
745                                                  UINT8 *p_mcl_idx);
746     extern BOOLEAN bta_hl_find_an_in_use_app_idx(UINT8 *p_app_idx);
747     extern BOOLEAN bta_hl_find_app_idx(UINT8 app_id, UINT8 *p_app_idx);
748     extern BOOLEAN bta_hl_find_app_idx_using_handle(tBTA_HL_APP_HANDLE app_handle,
749                                                     UINT8 *p_app_idx);
750     extern BOOLEAN bta_hl_find_mcl_idx_using_handle( tBTA_HL_MCL_HANDLE mcl_handle,
751                                                      UINT8 *p_app_idx, UINT8 *p_mcl_idx);
752     extern BOOLEAN bta_hl_find_mcl_idx(UINT8 app_idx, BD_ADDR p_bd_addr, UINT8 *p_mcl_idx);
753     extern BOOLEAN bta_hl_is_the_first_reliable_existed(UINT8 app_idx, UINT8 mcl_idx );
754     extern BOOLEAN  bta_hl_find_non_active_mdl_cfg(UINT8 app_idx, UINT8 start_mdl_cfg_idx,
755                                                    UINT8 *p_mdl_cfg_idx);
756     extern BOOLEAN  bta_hl_find_avail_mdl_cfg_idx(UINT8 app_idx, UINT8 mcl_idx,
757                                                   UINT8 *p_mdl_cfg_idx);
758     extern BOOLEAN  bta_hl_find_mdl_cfg_idx(UINT8 app_idx, UINT8 mcl_idx,
759                                             tBTA_HL_MDL_ID mdl_id, UINT8 *p_mdl_cfg_idx);
760     extern BOOLEAN  bta_hl_get_cur_time(UINT8 app_idx, UINT8 *p_cur_time);
761     extern void bta_hl_sort_cfg_time_idx(UINT8 app_idx, UINT8 *a, UINT8 n);
762     extern void  bta_hl_compact_mdl_cfg_time(UINT8 app_idx, UINT8 mdep_id);
763     extern BOOLEAN  bta_hl_is_mdl_exsit_in_mcl(UINT8 app_idx, BD_ADDR bd_addr,
764                                                tBTA_HL_MDL_ID mdl_id);
765     extern BOOLEAN  bta_hl_delete_mdl_cfg(UINT8 app_idx, BD_ADDR bd_addr,
766                                           tBTA_HL_MDL_ID mdl_id);
767     extern BOOLEAN  bta_hl_is_mdl_value_valid(tBTA_HL_MDL_ID mdl_id);
768     extern BOOLEAN bta_hl_find_mdep_cfg_idx(UINT8 app_idx,
769                                             tBTA_HL_MDEP_ID local_mdep_id, UINT8 *p_mdep_cfg_idx);
770     extern void bta_hl_find_rxtx_apdu_size(UINT8 app_idx, UINT8 mdep_cfg_idx,
771                                            UINT16 *p_rx_apu_size,
772                                            UINT16 *p_tx_apu_size);
773     extern BOOLEAN bta_hl_validate_peer_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
774                                             tBTA_HL_MDEP_ID peer_mdep_id,
775                                             tBTA_HL_MDEP_ROLE peer_mdep_role,
776                                             UINT8 sdp_idx);
777     extern tBTA_HL_STATUS bta_hl_chk_local_cfg(UINT8 app_idx, UINT8 mcl_idx,
778                                                UINT8 mdep_cfg_idx,
779                                                tBTA_HL_DCH_CFG local_cfg);
780 
781     extern BOOLEAN bta_hl_validate_reconnect_params(UINT8 app_idx, UINT8 mcl_idx,
782                                                     tBTA_HL_API_DCH_RECONNECT *p_reconnect,
783                                                     UINT8 *p_mdep_cfg_idx, UINT8 *p_mdl_cfg_idx);
784     extern BOOLEAN bta_hl_find_avail_mcl_idx(UINT8 app_idx, UINT8 *p_mcl_idx);
785     extern BOOLEAN bta_hl_find_avail_mdl_idx(UINT8 app_idx, UINT8 mcl_idx,
786                                              UINT8 *p_mdl_idx);
787     extern BOOLEAN bta_hl_is_a_duplicate_id(UINT8 app_id);
788     extern BOOLEAN bta_hl_find_avail_app_idx(UINT8 *p_idx);
789     extern tBTA_HL_STATUS bta_hl_app_update(UINT8 app_id, BOOLEAN is_register);
790     extern tBTA_HL_STATUS bta_hl_app_registration(UINT8 app_idx);
791     extern void bta_hl_discard_data(UINT16 event, tBTA_HL_DATA *p_data);
792     extern void bta_hl_save_mdl_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx );
793     extern void bta_hl_set_dch_chan_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx, tBTA_HL_DATA *p_data);
794     extern BOOLEAN bta_hl_get_l2cap_cfg(tBTA_HL_MDL_HANDLE mdl_hnd, tBTA_HL_L2CAP_CFG_INFO *p_cfg);
795     extern BOOLEAN bta_hl_validate_chan_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx);
796     extern BOOLEAN bta_hl_is_cong_on(UINT8 app_id, BD_ADDR bd_addr, tBTA_HL_MDL_ID mdl_id);
797     extern void bta_hl_check_cch_close(UINT8 app_idx, UINT8 mcl_idx,
798                                        tBTA_HL_DATA *p_data, BOOLEAN check_dch_setup);
799     extern void bta_hl_clean_app(UINT8 app_idx);
800     extern void bta_hl_check_deregistration(UINT8 app_idx, tBTA_HL_DATA *p_data );
801     extern void bta_hl_check_disable(tBTA_HL_DATA *p_data );
802     extern void  bta_hl_build_abort_ind(tBTA_HL *p_evt_data,
803                                         tBTA_HL_APP_HANDLE app_handle,
804                                         tBTA_HL_MCL_HANDLE mcl_handle);
805     extern void  bta_hl_build_abort_cfm(tBTA_HL *p_evt_data,
806                                         tBTA_HL_APP_HANDLE app_handle,
807                                         tBTA_HL_MCL_HANDLE mcl_handle,
808                                         tBTA_HL_STATUS status);
809     extern void  bta_hl_build_dch_close_cfm(tBTA_HL *p_evt_data,
810                                             tBTA_HL_APP_HANDLE app_handle,
811                                             tBTA_HL_MCL_HANDLE mcl_handle,
812                                             tBTA_HL_MDL_HANDLE mdl_handle,
813                                             tBTA_HL_STATUS status);
814     extern void  bta_hl_build_dch_close_ind(tBTA_HL *p_evt_data,
815                                             tBTA_HL_APP_HANDLE app_handle,
816                                             tBTA_HL_MCL_HANDLE mcl_handle,
817                                             tBTA_HL_MDL_HANDLE mdl_handle,
818                                             BOOLEAN intentional);
819     extern void  bta_hl_build_send_data_cfm(tBTA_HL *p_evt_data,
820                                             tBTA_HL_APP_HANDLE app_handle,
821                                             tBTA_HL_MCL_HANDLE mcl_handle,
822                                             tBTA_HL_MDL_HANDLE mdl_handle,
823                                             tBTA_HL_STATUS status );
824     extern void  bta_hl_build_rcv_data_ind(tBTA_HL *p_evt_data,
825                                            tBTA_HL_APP_HANDLE app_handle,
826                                            tBTA_HL_MCL_HANDLE mcl_handle,
827                                            tBTA_HL_MDL_HANDLE mdl_handle);
828     extern void  bta_hl_build_cch_open_cfm(tBTA_HL *p_evt_data,
829                                             UINT8 app_id,
830                                            tBTA_HL_APP_HANDLE app_handle,
831                                            tBTA_HL_MCL_HANDLE mcl_handle,
832                                            BD_ADDR bd_addr,
833                                            tBTA_HL_STATUS status );
834     extern void  bta_hl_build_cch_open_ind(tBTA_HL *p_evt_data,
835                                            tBTA_HL_APP_HANDLE app_handle,
836                                            tBTA_HL_MCL_HANDLE mcl_handle,
837                                            BD_ADDR bd_addr);
838     extern void  bta_hl_build_cch_close_cfm(tBTA_HL *p_evt_data,
839                                             tBTA_HL_APP_HANDLE app_handle,
840                                             tBTA_HL_MCL_HANDLE mcl_handle,
841                                             tBTA_HL_STATUS status );
842     extern void   bta_hl_build_cch_close_ind(tBTA_HL *p_evt_data,
843                                              tBTA_HL_APP_HANDLE app_handle,
844                                              tBTA_HL_MCL_HANDLE mcl_handle,
845                                              BOOLEAN intentional);
846 
847     extern void  bta_hl_build_dch_open_cfm(tBTA_HL *p_evt_data,
848                                            tBTA_HL_APP_HANDLE app_handle,
849                                            tBTA_HL_MCL_HANDLE mcl_handle,
850                                            tBTA_HL_MDL_HANDLE mdl_handle,
851                                            tBTA_HL_MDEP_ID local_mdep_id,
852                                            tBTA_HL_MDL_ID mdl_id,
853                                            tBTA_HL_DCH_MODE dch_mode,
854                                            BOOLEAN first_reliable,
855                                            UINT16 mtu,
856                                            tBTA_HL_STATUS status);
857 
858     extern void  bta_hl_build_delete_mdl_cfm(tBTA_HL *p_evt_data,
859                                              tBTA_HL_APP_HANDLE app_handle,
860                                              tBTA_HL_MCL_HANDLE mcl_handle,
861                                              tBTA_HL_MDL_ID mdl_id,
862                                              tBTA_HL_STATUS status);
863     extern void  bta_hl_build_echo_test_cfm(tBTA_HL *p_evt_data,
864                                             tBTA_HL_APP_HANDLE app_handle,
865                                             tBTA_HL_MCL_HANDLE mcl_handle,
866                                             tBTA_HL_STATUS status );
867     extern void  bta_hl_build_sdp_query_cfm(tBTA_HL *p_evt_data,
868                                             UINT8 app_id,
869                                             tBTA_HL_APP_HANDLE app_handle,
870                                             BD_ADDR bd_addr,
871                                             tBTA_HL_SDP *p_sdp,
872                                             tBTA_HL_STATUS status);
873 
874 #if (BTA_HL_DEBUG == TRUE)
875     extern  char *bta_hl_status_code(tBTA_HL_STATUS status);
876     extern char *bta_hl_evt_code(tBTA_HL_INT_EVT evt_code);
877 #endif
878 #ifdef __cplusplus
879 }
880 #endif
881 #endif /* BTA_MSE_INT_H */
882 
883 
884