NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
l2c_api.h
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 *
21 * this file contains the L2CAP API definitions
22 *
23 ******************************************************************************/
24#ifndef L2C_API_H
25#define L2C_API_H
26
27#include "bt_target.h"
28#include "l2cdefs.h"
29#include "hcidefs.h"
30
31/*****************************************************************************
32** Constants
33*****************************************************************************/
34
35/* Define the minimum offset that L2CAP needs in a buffer. This is made up of
36** HCI type(1), len(2), handle(2), L2CAP len(2) and CID(2) => 9
37*/
38#define L2CAP_MIN_OFFSET 13 /* plus control(2), SDU length(2) */
39
40/* Minimum offset for broadcast needs another two bytes for the PSM */
41#define L2CAP_BCST_MIN_OFFSET 11
42
43/* ping result codes */
44#define L2CAP_PING_RESULT_OK 0 /* Ping reply received OK */
45#define L2CAP_PING_RESULT_NO_LINK 1 /* Link could not be setup */
46#define L2CAP_PING_RESULT_NO_RESP 2 /* Remote L2CAP did not reply */
47
48/* result code for L2CA_DataWrite() */
49#define L2CAP_DW_FAILED FALSE
50#define L2CAP_DW_SUCCESS TRUE
51#define L2CAP_DW_CONGESTED 2
52
53/* Values for priority parameter to L2CA_SetAclPriority */
54#define L2CAP_PRIORITY_NORMAL 0
55#define L2CAP_PRIORITY_HIGH 1
56
57/* Values for priority parameter to L2CA_SetTxPriority */
58#define L2CAP_CHNL_PRIORITY_HIGH 0
59#define L2CAP_CHNL_PRIORITY_MEDIUM 1
60#define L2CAP_CHNL_PRIORITY_LOW 2
61
62typedef UINT8 tL2CAP_CHNL_PRIORITY;
63
64/* Values for Tx/Rx data rate parameter to L2CA_SetChnlDataRate */
65#define L2CAP_CHNL_DATA_RATE_HIGH 3
66#define L2CAP_CHNL_DATA_RATE_MEDIUM 2
67#define L2CAP_CHNL_DATA_RATE_LOW 1
68#define L2CAP_CHNL_DATA_RATE_NO_TRAFFIC 0
69
70typedef UINT8 tL2CAP_CHNL_DATA_RATE;
71
72/* Data Packet Flags (bits 2-15 are reserved) */
73/* layer specific 14-15 bits are used for FCR SAR */
74#define L2CAP_FLUSHABLE_MASK 0x0003
75#define L2CAP_FLUSHABLE_CH_BASED 0x0000
76#define L2CAP_FLUSHABLE_PKT 0x0001
77#define L2CAP_NON_FLUSHABLE_PKT 0x0002
78
79
80/* L2CA_FlushChannel num_to_flush definitions */
81#define L2CAP_FLUSH_CHANS_ALL 0xffff
82#define L2CAP_FLUSH_CHANS_GET 0x0000
83
84
85/* special CID for Multi-AV for reporting congestion */
86#define L2CAP_MULTI_AV_CID 0
87
88/* length of the HCI header block */
89/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) */
90#define L2CAP_MULTI_AV_HCI_HDR_LEN 8
91
92/* length of padding for 4 bytes align */
93#define L2CAP_MULTI_AV_PADDING_LEN 2
94
95/* length of the HCI header block with padding for FCR */
96/* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) + padding(2) */
97#define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING 10
98
99/* length of the L2CAP header block */
100/* HCI header(4) + L2CAP header(4) + padding(4) or control word(2) + FCS(2) */
101#define L2CAP_MULTI_AV_L2C_HDR_LEN 12
102
103/* definition used for L2CA_SetDesireRole */
104#define L2CAP_ROLE_SLAVE HCI_ROLE_SLAVE
105#define L2CAP_ROLE_MASTER HCI_ROLE_MASTER
106#define L2CAP_ROLE_ALLOW_SWITCH 0x80 /* set this bit to allow switch at create conn */
107#define L2CAP_ROLE_DISALLOW_SWITCH 0x40 /* set this bit to disallow switch at create conn */
108#define L2CAP_ROLE_CHECK_SWITCH 0xC0
109
110
111/* Values for 'allowed_modes' field passed in structure tL2CAP_ERTM_INFO
112*/
113#define L2CAP_FCR_CHAN_OPT_BASIC (1 << L2CAP_FCR_BASIC_MODE)
114#define L2CAP_FCR_CHAN_OPT_ERTM (1 << L2CAP_FCR_ERTM_MODE)
115#define L2CAP_FCR_CHAN_OPT_STREAM (1 << L2CAP_FCR_STREAM_MODE)
116
117#define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
118
119/* Validity check for PSM. PSM values must be odd. Also, all PSM values must
120** be assigned such that the least significant bit of the most sigificant
121** octet equals zero.
122*/
123#define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
124#define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
125
126#if (BLE_INCLUDED == TRUE)
127#define L2CAP_LE_INT_MIN 0x0006
128#define L2CAP_LE_INT_MAX 0x0C80
129#define L2CAP_LE_LATENCY_MAX 500
130#define L2CAP_LE_TIMEOUT_MIN 0x000a
131#define L2CAP_LE_TIMEOUT_MAX 0x0C80
132#define L2CAP_LE_TIMEOUT_DEFAULT 0x07D0
133#endif
134
135
136/*****************************************************************************
137** Type Definitions
138*****************************************************************************/
139
140typedef struct
141{
142#define L2CAP_FCR_BASIC_MODE 0x00
143#define L2CAP_FCR_ERTM_MODE 0x03
144#define L2CAP_FCR_STREAM_MODE 0x04
145
146 UINT8 mode;
147
148 UINT8 tx_win_sz;
149 UINT8 max_transmit;
150 UINT16 rtrans_tout;
151 UINT16 mon_tout;
152 UINT16 mps;
154
155/* Define a structure to hold the configuration parameters. Since the
156** parameters are optional, for each parameter there is a boolean to
157** use to signify its presence or absence.
158*/
159typedef struct
160{
161 UINT16 result; /* Only used in confirm messages */
162 BOOLEAN mtu_present;
163 UINT16 mtu;
164 BOOLEAN qos_present;
165 FLOW_SPEC qos;
166 BOOLEAN flush_to_present;
167 UINT16 flush_to;
168 BOOLEAN fcr_present;
169 tL2CAP_FCR_OPTS fcr;
170 BOOLEAN fcs_present; /* Optionally bypasses FCS checks */
171 UINT8 fcs; /* '0' if desire is to bypass FCS, otherwise '1' */
172 BOOLEAN ext_flow_spec_present;
173 tHCI_EXT_FLOW_SPEC ext_flow_spec;
174 UINT16 flags; /* bit 0: 0-no continuation, 1-continuation */
176
177/* L2CAP channel configured field bitmap */
178#define L2CAP_CH_CFG_MASK_MTU 0x0001
179#define L2CAP_CH_CFG_MASK_QOS 0x0002
180#define L2CAP_CH_CFG_MASK_FLUSH_TO 0x0004
181#define L2CAP_CH_CFG_MASK_FCR 0x0008
182#define L2CAP_CH_CFG_MASK_FCS 0x0010
183#define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC 0x0020
184
185typedef UINT16 tL2CAP_CH_CFG_BITS;
186
187/*********************************
188** Callback Functions Prototypes
189**********************************/
190
191/* Connection indication callback prototype. Parameters are
192** BD Address of remote
193** Local CID assigned to the connection
194** PSM that the remote wants to connect to
195** Identifier that the remote sent
196*/
197typedef void (tL2CA_CONNECT_IND_CB) (BD_ADDR, UINT16, UINT16, UINT8);
198
199
200/* Connection confirmation callback prototype. Parameters are
201** Local CID
202** Result - 0 = connected, non-zero means failure reason
203*/
204typedef void (tL2CA_CONNECT_CFM_CB) (UINT16, UINT16);
205
206
207/* Connection pending callback prototype. Parameters are
208** Local CID
209*/
210typedef void (tL2CA_CONNECT_PND_CB) (UINT16);
211
212
213/* Configuration indication callback prototype. Parameters are
214** Local CID assigned to the connection
215** Pointer to configuration info
216*/
217typedef void (tL2CA_CONFIG_IND_CB) (UINT16, tL2CAP_CFG_INFO *);
218
219
220/* Configuration confirm callback prototype. Parameters are
221** Local CID assigned to the connection
222** Pointer to configuration info
223*/
224typedef void (tL2CA_CONFIG_CFM_CB) (UINT16, tL2CAP_CFG_INFO *);
225
226
227/* Disconnect indication callback prototype. Parameters are
228** Local CID
229** Boolean whether upper layer should ack this
230*/
231typedef void (tL2CA_DISCONNECT_IND_CB) (UINT16, BOOLEAN);
232
233
234/* Disconnect confirm callback prototype. Parameters are
235** Local CID
236** Result
237*/
238typedef void (tL2CA_DISCONNECT_CFM_CB) (UINT16, UINT16);
239
240
241/* QOS Violation indication callback prototype. Parameters are
242** BD Address of violating device
243*/
244typedef void (tL2CA_QOS_VIOLATION_IND_CB) (BD_ADDR);
245
246
247/* Data received indication callback prototype. Parameters are
248** Local CID
249** Address of buffer
250*/
251typedef void (tL2CA_DATA_IND_CB) (UINT16, BT_HDR *);
252
253
254/* Echo response callback prototype. Note that this is not included in the
255** registration information, but is passed to L2CAP as part of the API to
256** actually send an echo request. Parameters are
257** Result
258*/
259typedef void (tL2CA_ECHO_RSP_CB) (UINT16);
260
261
262/* Callback function prototype to pass broadcom specific echo response */
263/* to the upper layer */
264typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
265
266
267/* Congestion status callback protype. This callback is optional. If
268** an application tries to send data when the transmit queue is full,
269** the data will anyways be dropped. The parameter is:
270** Local CID
271** TRUE if congested, FALSE if uncongested
272*/
273typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
274
275/* Callback prototype for number of packets completed events.
276** This callback notifies the application when Number of Completed Packets
277** event has been received.
278** This callback is originally designed for 3DG devices.
279** The parameter is:
280** peer BD_ADDR
281*/
282typedef void (tL2CA_NOCP_CB) (BD_ADDR);
283
284/* Transmit complete callback protype. This callback is optional. If
285** set, L2CAP will call it when packets are sent or flushed. If the
286** count is 0xFFFF, it means all packets are sent for that CID (eRTM
287** mode only). The parameters are:
288** Local CID
289** Number of SDUs sent or dropped
290*/
291typedef void (tL2CA_TX_COMPLETE_CB) (UINT16, UINT16);
292
293/* Define the structure that applications use to register with
294** L2CAP. This structure includes callback functions. All functions
295** MUST be provided, with the exception of the "connect pending"
296** callback and "congestion status" callback.
297*/
298typedef struct
299{
300 tL2CA_CONNECT_IND_CB *pL2CA_ConnectInd_Cb;
301 tL2CA_CONNECT_CFM_CB *pL2CA_ConnectCfm_Cb;
302 tL2CA_CONNECT_PND_CB *pL2CA_ConnectPnd_Cb;
303 tL2CA_CONFIG_IND_CB *pL2CA_ConfigInd_Cb;
304 tL2CA_CONFIG_CFM_CB *pL2CA_ConfigCfm_Cb;
305 tL2CA_DISCONNECT_IND_CB *pL2CA_DisconnectInd_Cb;
306 tL2CA_DISCONNECT_CFM_CB *pL2CA_DisconnectCfm_Cb;
307 tL2CA_QOS_VIOLATION_IND_CB *pL2CA_QoSViolationInd_Cb;
308 tL2CA_DATA_IND_CB *pL2CA_DataInd_Cb;
309 tL2CA_CONGESTION_STATUS_CB *pL2CA_CongestionStatus_Cb;
310 tL2CA_TX_COMPLETE_CB *pL2CA_TxComplete_Cb;
311
313
314/* Define the structure that applications use to create or accept
315** connections with enhanced retransmission mode.
316*/
317typedef struct
318{
319 UINT8 preferred_mode;
320 UINT8 allowed_modes;
321 UINT8 user_rx_pool_id;
322 UINT8 user_tx_pool_id;
323 UINT8 fcr_rx_pool_id;
324 UINT8 fcr_tx_pool_id;
325
327
328#define L2CA_REGISTER(a,b,c) L2CA_Register(a,(tL2CAP_APPL_INFO *)b)
329#define L2CA_DEREGISTER(a) L2CA_Deregister(a)
330#define L2CA_CONNECT_REQ(a,b,c,d) L2CA_ErtmConnectReq(a,b,c)
331#define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f)
332#define L2CA_CONFIG_REQ(a,b) L2CA_ConfigReq(a,b)
333#define L2CA_CONFIG_RSP(a,b) L2CA_ConfigRsp(a,b)
334#define L2CA_DISCONNECT_REQ(a) L2CA_DisconnectReq(a)
335#define L2CA_DISCONNECT_RSP(a) L2CA_DisconnectRsp(a)
336#define L2CA_DATA_WRITE(a, b) L2CA_DataWrite(a, b)
337
338/*****************************************************************************
339** External Function Declarations
340*****************************************************************************/
341#ifdef __cplusplus
342extern "C"
343{
344#endif
345
346/*******************************************************************************
347**
348** Function L2CA_Register
349**
350** Description Other layers call this function to register for L2CAP
351** services.
352**
353** Returns PSM to use or zero if error. Typically, the PSM returned
354** is the same as was passed in, but for an outgoing-only
355** connection to a dynamic PSM, a "virtual" PSM is returned
356** and should be used in the calls to L2CA_ConnectReq() and
357** BTM_SetSecurityLevel().
358**
359*******************************************************************************/
360L2C_API extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
361
362/*******************************************************************************
363**
364** Function L2CA_Deregister
365**
366** Description Other layers call this function to deregister for L2CAP
367** services.
368**
369** Returns void
370**
371*******************************************************************************/
372L2C_API extern void L2CA_Deregister (UINT16 psm);
373
374/*******************************************************************************
375**
376** Function L2CA_AllocatePSM
377**
378** Description Other layers call this function to find an unused PSM for L2CAP
379** services.
380**
381** Returns PSM to use.
382**
383*******************************************************************************/
384L2C_API extern UINT16 L2CA_AllocatePSM(void);
385
386/*******************************************************************************
387**
388** Function L2CA_ConnectReq
389**
390** Description Higher layers call this function to create an L2CAP connection.
391** Note that the connection is not established at this time, but
392** connection establishment gets started. The callback function
393** will be invoked when connection establishes or fails.
394**
395** Returns the CID of the connection, or 0 if it failed to start
396**
397*******************************************************************************/
398L2C_API extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr);
399
400/*******************************************************************************
401**
402** Function L2CA_ConnectRsp
403**
404** Description Higher layers call this function to accept an incoming
405** L2CAP connection, for which they had gotten an connect
406** indication callback.
407**
408** Returns TRUE for success, FALSE for failure
409**
410*******************************************************************************/
411L2C_API extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
412 UINT16 result, UINT16 status);
413
414/*******************************************************************************
415**
416** Function L2CA_ErtmConnectReq
417**
418** Description Higher layers call this function to create an L2CAP connection
419** that needs to use Enhanced Retransmission Mode.
420** Note that the connection is not established at this time, but
421** connection establishment gets started. The callback function
422** will be invoked when connection establishes or fails.
423**
424** Returns the CID of the connection, or 0 if it failed to start
425**
426*******************************************************************************/
427L2C_API extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
428 tL2CAP_ERTM_INFO *p_ertm_info);
429
430/*******************************************************************************
431**
432** Function L2CA_ErtmConnectRsp
433**
434** Description Higher layers call this function to accept an incoming
435** L2CAP connection, for which they had gotten an connect
436** indication callback, and for which the higher layer wants
437** to use Enhanced Retransmission Mode.
438**
439** Returns TRUE for success, FALSE for failure
440**
441*******************************************************************************/
442L2C_API extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
443 UINT16 result, UINT16 status,
444 tL2CAP_ERTM_INFO *p_ertm_info);
445
446/*******************************************************************************
447**
448** Function L2CA_ConfigReq
449**
450** Description Higher layers call this function to send configuration.
451**
452** Returns TRUE if configuration sent, else FALSE
453**
454*******************************************************************************/
455L2C_API extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
456
457/*******************************************************************************
458**
459** Function L2CA_ConfigRsp
460**
461** Description Higher layers call this function to send a configuration
462** response.
463**
464** Returns TRUE if configuration response sent, else FALSE
465**
466*******************************************************************************/
467L2C_API extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
468
469/*******************************************************************************
470**
471** Function L2CA_DisconnectReq
472**
473** Description Higher layers call this function to disconnect a channel.
474**
475** Returns TRUE if disconnect sent, else FALSE
476**
477*******************************************************************************/
478L2C_API extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
479
480/*******************************************************************************
481**
482** Function L2CA_DisconnectRsp
483**
484** Description Higher layers call this function to acknowledge the
485** disconnection of a channel.
486**
487** Returns void
488**
489*******************************************************************************/
490L2C_API extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
491
492/*******************************************************************************
493**
494** Function L2CA_DataWrite
495**
496** Description Higher layers call this function to write data.
497**
498** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
499** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
500** L2CAP_DW_FAILED, if error
501**
502*******************************************************************************/
503L2C_API extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
504
505/*******************************************************************************
506**
507** Function L2CA_Ping
508**
509** Description Higher layers call this function to send an echo request.
510**
511** Returns TRUE if echo request sent, else FALSE.
512**
513*******************************************************************************/
514L2C_API extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
515
516/*******************************************************************************
517**
518** Function L2CA_Echo
519**
520** Description Higher layers call this function to send an echo request
521** with application-specific data.
522**
523** Returns TRUE if echo request sent, else FALSE.
524**
525*******************************************************************************/
526L2C_API extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
527
528/*******************************************************************************
529**
530** Function L2CA_SetIdleTimeout
531**
532** Description Higher layers call this function to set the idle timeout for
533** a connection, or for all future connections. The "idle timeout"
534** is the amount of time that a connection can remain up with
535** no L2CAP channels on it. A timeout of zero means that the
536** connection will be torn down immediately when the last channel
537** is removed. A timeout of 0xFFFF means no timeout. Values are
538** in seconds.
539**
540** Returns TRUE if command succeeded, FALSE if failed
541**
542*******************************************************************************/
543L2C_API extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
544 BOOLEAN is_global);
545
546/*******************************************************************************
547**
548** Function L2CA_SetIdleTimeoutByBdAddr
549**
550** Description Higher layers call this function to set the idle timeout for
551** a connection. The "idle timeout" is the amount of time that
552** a connection can remain up with no L2CAP channels on it.
553** A timeout of zero means that the connection will be torn
554** down immediately when the last channel is removed.
555** A timeout of 0xFFFF means no timeout. Values are in seconds.
556** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
557** then the idle timeouts for all active l2cap links will be
558** changed.
559**
560** Returns TRUE if command succeeded, FALSE if failed
561**
562** NOTE This timeout applies to all logical channels active on the
563** ACL link.
564*******************************************************************************/
565L2C_API extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout);
566
567/*******************************************************************************
568**
569** Function L2CA_SetTraceLevel
570**
571** Description This function sets the trace level for L2CAP. If called with
572** a value of 0xFF, it simply reads the current trace level.
573**
574** Returns the new (current) trace level
575**
576*******************************************************************************/
577L2C_API extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
578
579/*******************************************************************************
580**
581** Function L2CA_SetDesireRole
582**
583** Description This function sets the desire role for L2CAP.
584** If the new role is L2CAP_ROLE_ALLOW_SWITCH, allow switch on
585** HciCreateConnection.
586** If the new role is L2CAP_ROLE_DISALLOW_SWITCH, do not allow switch on
587** HciCreateConnection.
588**
589** If the new role is a valid role (HCI_ROLE_MASTER or HCI_ROLE_SLAVE),
590** the desire role is set to the new value. Otherwise, it is not changed.
591**
592** Returns the new (current) role
593**
594*******************************************************************************/
595L2C_API extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
596
597/*******************************************************************************
598**
599** Function L2CA_LocalLoopbackReq
600**
601** Description This function sets up a CID for local loopback
602**
603** Returns CID of 0 if none.
604**
605*******************************************************************************/
606L2C_API extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr);
607
608/*******************************************************************************
609**
610** Function L2CA_FlushChannel
611**
612** Description This function flushes none, some or all buffers queued up
613** for xmission for a particular CID. If called with
614** L2CAP_FLUSH_CHANS_GET (0), it simply returns the number
615** of buffers queued for that CID L2CAP_FLUSH_CHANS_ALL (0xffff)
616** flushes all buffers. All other values specifies the maximum
617** buffers to flush.
618**
619** Returns Number of buffers left queued for that CID
620**
621*******************************************************************************/
622L2C_API extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush);
623
624
625/*******************************************************************************
626**
627** Function L2CA_SetAclPriority
628**
629** Description Sets the transmission priority for an ACL channel.
630** (For initial implementation only two values are valid.
631** L2CAP_PRIORITY_NORMAL and L2CAP_PRIORITY_HIGH).
632**
633** Returns TRUE if a valid channel, else FALSE
634**
635*******************************************************************************/
636L2C_API extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority);
637
638/*******************************************************************************
639**
640** Function L2CA_FlowControl
641**
642** Description Higher layers call this function to flow control a channel.
643**
644** data_enabled - TRUE data flows, FALSE data is stopped
645**
646** Returns TRUE if valid channel, else FALSE
647**
648*******************************************************************************/
649L2C_API extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled);
650
651/*******************************************************************************
652**
653** Function L2CA_SendTestSFrame
654**
655** Description Higher layers call this function to send a test S-frame.
656**
657** Returns TRUE if valid Channel, else FALSE
658**
659*******************************************************************************/
660L2C_API extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, BOOLEAN rr_or_rej,
661 UINT8 back_track);
662
663/*******************************************************************************
664**
665** Function L2CA_SetTxPriority
666**
667** Description Sets the transmission priority for a channel. (FCR Mode)
668**
669** Returns TRUE if a valid channel, else FALSE
670**
671*******************************************************************************/
672L2C_API extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority);
673
674/*******************************************************************************
675**
676** Function L2CA_RegForNoCPEvt
677**
678** Description Register callback for Number of Completed Packets event.
679**
680** Input Param p_cb - callback for Number of completed packets event
681** p_bda - BT address of remote device
682**
683** Returns
684**
685*******************************************************************************/
686L2C_API extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda);
687
688/*******************************************************************************
689**
690** Function L2CA_SetChnlDataRate
691**
692** Description Sets the tx/rx data rate for a channel.
693**
694** Returns TRUE if a valid channel, else FALSE
695**
696*******************************************************************************/
697L2C_API extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx);
698
699typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
700
701/*******************************************************************************
702**
703** Function L2CA_SetFlushTimeout
704**
705** Description This function set the automatic flush time out in Baseband
706** for ACL-U packets.
707** BdAddr : the remote BD address of ACL link. If it is BT_DB_ANY
708** then the flush time out will be applied to all ACL link.
709** FlushTimeout: flush time out in ms
710** 0x0000 : No automatic flush
711** L2CAP_NO_RETRANSMISSION : No retransmission
712** 0x0002 - 0xFFFE : flush time out, if (flush_tout*8)+3/5)
713** <= HCI_MAX_AUTO_FLUSH_TOUT (in 625us slot).
714** Otherwise, return FALSE.
715** L2CAP_NO_AUTOMATIC_FLUSH : No automatic flush
716**
717** Returns TRUE if command succeeded, FALSE if failed
718**
719** NOTE This flush timeout applies to all logical channels active on the
720** ACL link.
721*******************************************************************************/
722L2C_API extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
723
724/*******************************************************************************
725**
726** Function L2CA_DataWriteEx
727**
728** Description Higher layers call this function to write data with extended
729** flags.
730** flags : L2CAP_FLUSHABLE_CH_BASED
731** L2CAP_FLUSHABLE_PKT
732** L2CAP_NON_FLUSHABLE_PKT
733**
734** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
735** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
736** L2CAP_DW_FAILED, if error
737**
738*******************************************************************************/
739L2C_API extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags);
740
741/*******************************************************************************
742**
743** Function L2CA_SetChnlFlushability
744**
745** Description Higher layers call this function to set a channels
746** flushability flags
747**
748** Returns TRUE if CID found, else FALSE
749**
750*******************************************************************************/
751L2C_API extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable);
752
753/*******************************************************************************
754**
755** Function L2CA_GetPeerFeatures
756**
757** Description Get a peers features and fixed channel map
758**
759** Parameters: BD address of the peer
760** Pointers to features and channel mask storage area
761**
762** Return value: TRUE if peer is connected
763**
764*******************************************************************************/
765L2C_API extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask);
766
767/*******************************************************************************
768**
769** Function L2CA_GetBDAddrbyHandle
770**
771** Description Get BD address for the given HCI handle
772**
773** Parameters: HCI handle
774** BD address of the peer
775**
776** Return value: TRUE if found lcb for the given handle, FALSE otherwise
777**
778*******************************************************************************/
779L2C_API extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
780
781/*******************************************************************************
782**
783** Function L2CA_GetChnlFcrMode
784**
785** Description Get the channel FCR mode
786**
787** Parameters: Local CID
788**
789** Return value: Channel mode
790**
791*******************************************************************************/
792L2C_API extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
793
794
795/*******************************************************************************
796**
797** UCD callback prototypes
798**
799*******************************************************************************/
800
801/* UCD discovery. Parameters are
802** BD Address of remote
803** Data Type
804** Data
805*/
806#define L2CAP_UCD_INFO_TYPE_RECEPTION 0x01
807#define L2CAP_UCD_INFO_TYPE_MTU 0x02
808
809typedef void (tL2CA_UCD_DISCOVER_CB) (BD_ADDR, UINT8, UINT32);
810
811/* UCD data received. Parameters are
812** BD Address of remote
813** Pointer to buffer with data
814*/
815typedef void (tL2CA_UCD_DATA_CB) (BD_ADDR, BT_HDR *);
816
817/* Congestion status callback protype. This callback is optional. If
818** an application tries to send data when the transmit queue is full,
819** the data will anyways be dropped. The parameter is:
820** remote BD_ADDR
821** TRUE if congested, FALSE if uncongested
822*/
823typedef void (tL2CA_UCD_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
824
825/* UCD registration info (the callback addresses and PSM)
826*/
827typedef struct
828{
829 tL2CA_UCD_DISCOVER_CB *pL2CA_UCD_Discover_Cb;
830 tL2CA_UCD_DATA_CB *pL2CA_UCD_Data_Cb;
831 tL2CA_UCD_CONGESTION_STATUS_CB *pL2CA_UCD_Congestion_Status_Cb;
833
834/*******************************************************************************
835**
836** Function L2CA_UcdRegister
837**
838** Description Register PSM on UCD.
839**
840** Parameters: tL2CAP_UCD_CB_INFO
841**
842** Return value: TRUE if successs
843**
844*******************************************************************************/
845L2C_API extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info );
846
847/*******************************************************************************
848**
849** Function L2CA_UcdDeregister
850**
851** Description Deregister PSM on UCD.
852**
853** Parameters: PSM
854**
855** Return value: TRUE if successs
856**
857*******************************************************************************/
858L2C_API extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm );
859
860/*******************************************************************************
861**
862** Function L2CA_UcdDiscover
863**
864** Description Discover UCD of remote device.
865**
866** Parameters: PSM
867** BD_ADDR of remote device
868** info_type : L2CAP_UCD_INFO_TYPE_RECEPTION
869** L2CAP_UCD_INFO_TYPE_MTU
870**
871**
872** Return value: TRUE if successs
873**
874*******************************************************************************/
875L2C_API extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type );
876
877/*******************************************************************************
878**
879** Function L2CA_UcdDataWrite
880**
881** Description Send UCD to remote device
882**
883** Parameters: PSM
884** BD Address of remote
885** Pointer to buffer of type BT_HDR
886** flags : L2CAP_FLUSHABLE_CH_BASED
887** L2CAP_FLUSHABLE_PKT
888** L2CAP_NON_FLUSHABLE_PKT
889**
890** Return value L2CAP_DW_SUCCESS, if data accepted
891** L2CAP_DW_FAILED, if error
892**
893*******************************************************************************/
894L2C_API extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags);
895
896/*******************************************************************************
897**
898** Function L2CA_UcdSetIdleTimeout
899**
900** Description Set UCD Idle timeout.
901**
902** Parameters: BD Addr
903** Timeout in second
904**
905** Return value: TRUE if successs
906**
907*******************************************************************************/
908L2C_API extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout );
909
910/*******************************************************************************
911**
912** Function L2CA_UCDSetTxPriority
913**
914** Description Sets the transmission priority for a connectionless channel.
915**
916** Returns TRUE if a valid channel, else FALSE
917**
918*******************************************************************************/
919L2C_API extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
920
921
922/*******************************************************************************
923**
924** Fixed Channel callback prototypes
925**
926*******************************************************************************/
927
928/* Fixed channel connected and disconnected. Parameters are
929** BD Address of remote
930** TRUE if channel is connected, FALSE if disconnected
931** Reason for connection failure
932*/
933typedef void (tL2CA_FIXED_CHNL_CB) (BD_ADDR, BOOLEAN, UINT16);
934
935/* Signalling data received. Parameters are
936** BD Address of remote
937** Pointer to buffer with data
938*/
939typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR, BT_HDR *);
940
941/* Fixed channel registration info (the callback addresses and channel config)
942*/
943typedef struct
944{
945 tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
946 tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
947 tL2CAP_FCR_OPTS fixed_chnl_opts;
948
949 UINT16 default_idle_tout;
951
952
953#if (L2CAP_NUM_FIXED_CHNLS > 0)
954/*******************************************************************************
955**
956** Function L2CA_RegisterFixedChannel
957**
958** Description Register a fixed channel.
959**
960** Parameters: Fixed Channel #
961** Channel Callbacks and config
962**
963** Return value: TRUE if registered OK
964**
965*******************************************************************************/
966L2C_API extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg);
967
968/*******************************************************************************
969**
970** Function L2CA_ConnectFixedChnl
971**
972** Description Connect an fixed signalling channel to a remote device.
973**
974** Parameters: Fixed CID
975** BD Address of remote
976**
977** Return value: TRUE if connection started
978**
979*******************************************************************************/
980L2C_API extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr);
981
982/*******************************************************************************
983**
984** Function L2CA_SendFixedChnlData
985**
986** Description Write data on a fixed signalling channel.
987**
988** Parameters: Fixed CID
989** BD Address of remote
990** Pointer to buffer of type BT_HDR
991**
992** Return value L2CAP_DW_SUCCESS, if data accepted
993** L2CAP_DW_FAILED, if error
994**
995*******************************************************************************/
996L2C_API extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf);
997
998/*******************************************************************************
999**
1000** Function L2CA_RemoveFixedChnl
1001**
1002** Description Remove a fixed channel to a remote device.
1003**
1004** Parameters: Fixed CID
1005** BD Address of remote
1006** Idle timeout to use (or 0xFFFF if don't care)
1007**
1008** Return value: TRUE if channel removed
1009**
1010*******************************************************************************/
1011L2C_API extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda);
1012
1013/*******************************************************************************
1014**
1015** Function L2CA_SetFixedChannelTout
1016**
1017** Description Higher layers call this function to set the idle timeout for
1018** a fixed channel. The "idle timeout" is the amount of time that
1019** a connection can remain up with no L2CAP channels on it.
1020** A timeout of zero means that the connection will be torn
1021** down immediately when the last channel is removed.
1022** A timeout of 0xFFFF means no timeout. Values are in seconds.
1023** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
1024** then the idle timeouts for all active l2cap links will be
1025** changed.
1026**
1027** Returns TRUE if command succeeded, FALSE if failed
1028**
1029*******************************************************************************/
1030L2C_API extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
1031
1032#endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
1033
1034/*******************************************************************************
1035**
1036** Function L2CA_GetCurrentConfig
1037**
1038** Description This function returns configurations of L2CAP channel
1039** pp_our_cfg : pointer of our saved configuration options
1040** p_our_cfg_bits : valid config in bitmap
1041** pp_peer_cfg: pointer of peer's saved configuration options
1042** p_peer_cfg_bits : valid config in bitmap
1043**
1044** Returns TRUE if successful
1045**
1046*******************************************************************************/
1047L2C_API extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
1048 tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits,
1049 tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits);
1050
1051#if (L2CAP_CORRUPT_ERTM_PKTS == TRUE)
1052/*******************************************************************************
1053**
1054** Function L2CA_SetupErtmTest
1055**
1056** Description This function is used for testing purposes only.
1057** It corrupts or drops one or more packets used with ERTM channels.
1058**
1059** Parameters
1060** cid - channel ID (0 uses RFCOMM PSM's CID)
1061**
1062** type - type of test to run (L2CAP_FCR_TTYPE_CORR_IFRAMES
1063** L2CAP_FCR_TTYPE_CORR_SFRAME
1064** L2CAP_FCR_TTYPE_STOP_TEST
1065** L2CAP_FCR_TTYPE_GET_CID - returns rfcomm cid only)
1066**
1067** is_rx - TRUE to corrupt Rx packet, FALSE for Tx packet)
1068**
1069** freq - L2CAP_FCR_FREQ_RANDOM (turns on random corruptions/drops)
1070** L2CAP_FCR_FREQ_NORMAL (turns on test with "count" corruptions/drops)
1071**
1072** count - number of packets in a row to drop or corrupt
1073**
1074** Returns CID of channel running test
1075**
1076*******************************************************************************/
1077L2C_API extern UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count);
1078
1079/*******************************************************************************
1080**
1081** Function L2CA_SendPolledSFrame
1082**
1083** Description This function is used for testing purposes only.
1084** It Sends a Polled RR or RNR to the peer
1085**
1086** Parameters
1087** cid - channel ID
1088**
1089** sup_type - (L2CAP_FCR_SUP_RR or L2CAP_FCR_SUP_RNR)
1090**
1091** Returns void
1092**
1093*******************************************************************************/
1094L2C_API extern void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type);
1095
1096/*******************************************************************************
1097**
1098** Function L2CA_BypassSFrame
1099**
1100** Description This function is used for testing purposes only.
1101** It skips sending 'count' S-Frames.
1102**
1103** Parameters
1104** cid - channel ID
1105**
1106** count - Number of S-Frames to skip sending
1107**
1108** Returns void
1109**
1110*******************************************************************************/
1111L2C_API extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count);
1112
1113#endif /* (L2CAP_CORRUPT_ERTM_PKTS == TRUE) */
1114
1115
1116#if (BLE_INCLUDED == TRUE)
1117/*******************************************************************************
1118**
1119** Function L2CA_CancelBleConnectReq
1120**
1121** Description Cancel a pending connection attempt to a BLE device.
1122**
1123** Parameters: BD Address of remote
1124**
1125** Return value: TRUE if connection was cancelled
1126**
1127*******************************************************************************/
1128L2C_API extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda);
1129
1130/*******************************************************************************
1131**
1132** Function L2CA_UpdateBleConnParams
1133**
1134** Description Update BLE connection parameters.
1135**
1136** Parameters: BD Address of remote
1137**
1138** Return value: TRUE if update started
1139**
1140*******************************************************************************/
1141L2C_API extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
1142
1143/*******************************************************************************
1144**
1145** Function L2CA_EnableUpdateBleConnParams
1146**
1147** Description Update BLE connection parameters.
1148**
1149** Parameters: BD Address of remote
1150** enable flag
1151**
1152** Return value: TRUE if update started
1153**
1154*******************************************************************************/
1155L2C_API extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
1156
1157/*******************************************************************************
1158**
1159** Function L2CA_GetBleConnRole
1160**
1161** Description This function returns the connection role.
1162**
1163** Returns link role.
1164**
1165*******************************************************************************/
1166L2C_API extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
1167
1168/*******************************************************************************
1169**
1170** Function L2CA_GetDisconnectReason
1171**
1172** Description This function returns the disconnect reason code.
1173**
1174** Returns disconnect reason
1175**
1176*******************************************************************************/
1177L2C_API extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda);
1178
1179#endif /* (BLE_INCLUDED == TRUE) */
1180
1181#ifdef __cplusplus
1182}
1183#endif
1184
1185#endif /* L2C_API_H */