1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef AVCTP_BR_L2CAP_H
16 #define AVCTP_BR_L2CAP_H
17 #include "avctp_int.h"
18 #include "l2cap_if.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 typedef struct {
23     uint16_t lcid;
24     uint8_t id;
25     L2capConnectionInfo info;
26     uint16_t lpsm;
27     void *ctx;
28 } AvctBrRecvConnectionReqCallbackTskParam;
29 
30 typedef struct {
31     uint16_t lcid;
32     L2capConnectionInfo info;
33     uint16_t result;
34     uint16_t status;
35     void *ctx;
36 } AvctBrRecvConnectionRspCallbackTskParam;
37 
38 typedef struct {
39     uint16_t lcid;
40     uint8_t id;
41     L2capConfigInfo cfg;
42     void *ctx;
43 } AvctBrRecvConfigReqCallbackTskParam;
44 
45 typedef struct {
46     uint16_t lcid;
47     L2capConfigInfo cfg;
48     uint16_t result;
49     void *ctx;
50 } AvctBrRecvConfigRspCallbackTskParam;
51 
52 typedef struct {
53     uint16_t lcid;
54     uint8_t id;
55     void *ctx;
56 } AvctBrRecvDisconnectionReqCallbackTskParam;
57 
58 typedef struct {
59     uint16_t lcid;
60     void *ctx;
61 } AvctBrRecvDisconnectionRspCallbackTskParam;
62 
63 typedef struct {
64     uint16_t lcid;
65     uint8_t reason;
66     void *ctx;
67 } AvctBrDisconnectAbnormalCallbackTskParam;
68 
69 typedef struct {
70     uint16_t lcid;
71     Packet *pkt;
72     void *ctx;
73 } AvctBrRecvDataCallbackTskParam;
74 
75 typedef struct {
76     uint16_t lcid;
77     uint8_t isBusy;
78     void *ctx;
79 } AvctBrRemoteBusyCallbackTskParam;
80 
81 typedef struct {
82     BtAddr addr;
83     uint16_t lcid;
84     int result;
85     void *context;
86 } AvctBrwL2CIFConnectReqCallbackTskParam;
87 
88 /* Connection Request packets received */
89 void AvctBrRecvConnectionReqCallback(
90     uint16_t lcid, uint8_t id, const L2capConnectionInfo *info, uint16_t lpsm, void *ctx);
91 void AvctBrRecvConnectionReqCallbackTsk(void *context);
92 void AvctBrRecvConnectionReqCBack(uint16_t lcid, uint8_t id, const L2capConnectionInfo *info, uint16_t lpsm, void *ctx);
93 /* Connection Response packet received */
94 void AvctBrRecvConnectionRspCallback(
95     uint16_t lcid, const L2capConnectionInfo *info, uint16_t result, uint16_t status, void *ctx);
96 void AvctBrRecvConnectionRspCallbackTsk(void *context);
97 void AvctBrRecvConnectionRspCBack(
98     uint16_t lcid, const L2capConnectionInfo *info, uint16_t result, uint16_t status, void *ctx);
99 /* Configuration Request packet received */
100 void AvctBrRecvConfigReqCallback(uint16_t lcid, uint8_t id, const L2capConfigInfo *cfg, void *ctx);
101 void AvctBrRecvConfigReqCallbackTsk(void *context);
102 void AvctBrRecvConfigReqCBack(uint16_t lcid, uint8_t id, const L2capConfigInfo *cfg, void *ctx);
103 /* Configuration Response packet received */
104 void AvctBrRecvConfigRspCallback(uint16_t lcid, const L2capConfigInfo *cfg, uint16_t result, void *ctx);
105 void AvctBrRecvConfigRspCallbackTsk(void *context);
106 void AvctBrRecvConfigRspCBack(uint16_t lcid, const L2capConfigInfo *cfg, uint16_t result, void *ctx);
107 /* Disconnection Request packet received */
108 void AvctBrRecvDisconnectionReqCallback(uint16_t lcid, uint8_t id, void *ctx);
109 void AvctBrRecvDisconnectionReqCallbackTsk(void *context);
110 void AvctBrRecvDisconnectionReqCBack(uint16_t lcid, uint8_t id, void *ctx);
111 /* Disconnection Response packet received */
112 void AvctBrRecvDisconnectionRspCallback(uint16_t lcid, void *ctx);
113 void AvctBrRecvDisconnectionRspCallbackTsk(void *context);
114 void AvctBrRecvDisconnectionRspCBack(uint16_t lcid, void *ctx);
115 /* Disconnected abnormal, such as acl disconnected or link loss */
116 void AvctBrDisconnectAbnormalCallback(uint16_t lcid, uint8_t reason, void *ctx);
117 void AvctBrDisconnectAbnormalCallbackTsk(void *context);
118 void AvctBrDisconnectAbnormalCBack(uint16_t lcid, uint8_t reason, void *ctx);
119 /* L2cap data packet received */
120 void AvctBrRecvDataCallback(uint16_t lcid, const Packet *pkt, void *ctx);
121 void AvctBrRecvDataCallbackTsk(void *context);
122 void AvctBrRecvDataCBack(uint16_t lcid, Packet *pkt, void *ctx);
123 /* In Enhanced Retransmission mode, when RNR received or tx_window overflow */
124 void AvctBrRemoteBusyCallback(uint16_t lcid, uint8_t isBusy, void *ctx);
125 void AvctBrRemoteBusyCallbackTsk(void *context);
126 void AvctBrRemoteBusyCBack(uint16_t lcid, uint8_t isBusy, void *ctx);
127 
128 extern void AvctBrRecvConnectionReqAct(const BtAddr *addr, uint16_t aclHandle, uint16_t lcid, uint8_t id, uint16_t psm);
129 extern void AvctBrwL2CIFConnectReqCallback(const BtAddr *addr, uint16_t lcid, int result, void *context);
130 
131 void AvctBrwL2CIFConnectReqCallbackTsk(void *context);
132 void AvctBrwL2CIFConnectResult(const BtAddr *addr, uint16_t lcid, int result, void *context);
133 
134 extern const L2capService G_AVCT_BR_L2C_SVR;
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 #endif /* AVCTP_BR_L2CAP_H */