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 16 #ifndef L2CAP_CORE_H 17 #define L2CAP_CORE_H 18 19 #include <stdint.h> 20 21 #include "alarm.h" 22 #include "list.h" 23 24 #include "l2cap_def.h" 25 #include "l2cap_inst.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif // __cplusplus 30 31 // configuration option type 32 #define L2CAP_OPTION_MAXIMUM_TRANSMISSION_UNIT 0x01 33 #define L2CAP_OPTION_FLUSH_TIMEOUT 0x02 34 #define L2CAP_OPTION_QUALITY_OF_SERVICE 0x03 35 #define L2CAP_OPTION_RETRANSMISSION_AND_FLOW_CONTROL 0x04 36 #define L2CAP_OPTION_FRAME_CHECK_SEQUENCE 0x05 37 #define L2CAP_OPTION_EXTENDED_FLOW_SPECIFICATION 0x06 38 #define L2CAP_OPTION_EXTENDED_WINDOW_SIZE 0x07 39 40 #define L2CAP_QOS_SERVICE_TYPE_BEST_EFFORT 0x01 41 #define L2CAP_QOS_SERVICE_TYPE_GUARANTEED 0x02 42 43 // for enhance mode 44 #define L2CAP_ERFC_UNSEGMENTED_SDU 0x00 45 #define L2CAP_ERFC_START_SDU 0x01 46 #define L2CAP_ERFC_END_SDU 0x02 47 #define L2CAP_ERFC_CONTINUATION_SDU 0x03 48 49 #define L2CAP_ERFC_RR 0x00 50 #define L2CAP_ERFC_REJ 0x01 51 #define L2CAP_ERFC_RNR 0x02 52 #define L2CAP_ERFC_SREJ 0x03 53 54 #define L2CAP_ERFC_PBIT_OFF 0x00 55 #define L2CAP_ERFC_PBIT_ON 0x01 56 57 #define L2CAP_ERFC_FBIT_OFF 0x00 58 #define L2CAP_ERFC_FBIT_ON 0x01 59 60 #define L2CAP_IFRAME 0x00 61 #define L2CAP_SFRAME 0x01 62 63 #define L2CAP_MAX_TX_WINDOW 64 64 65 // for callback 66 int L2capDisconnectComplete(uint16_t handle, uint8_t status, uint8_t reason); 67 int L2capConnectComplete(const BtAddr *addr, uint16_t handle, uint8_t status); 68 int L2capReceivePacket(uint16_t handle, uint16_t cid, Packet *pkt); 69 70 int L2capSendEchoReq(L2capConnection *conn, const uint8_t *data, uint16_t dataLen); 71 int L2capSendEchoRsp(L2capConnection *conn, uint8_t ident, const uint8_t *data, uint16_t dataLen); 72 int L2capSendConnectionReq(L2capConnection *conn, L2capChannel *chan); 73 int L2capSendConnectionRsp(L2capConnection *conn, L2capChannel *chan, uint8_t ident, uint16_t result, uint16_t status); 74 int L2capSendConfigurationReq(L2capConnection *conn, const L2capChannel *chan); 75 int L2capSendConfigurationRsp( 76 const L2capConnection *conn, L2capChannel *chan, uint8_t ident, uint16_t result, const L2capConfigInfo *cfg); 77 int L2capSendDisconnectionReq(L2capConnection *conn, L2capChannel *chan); 78 int L2capSendDisconnectionRsp(const L2capConnection *conn, const L2capChannel *chan, uint8_t ident); 79 int L2capSendInformationReq(L2capConnection *conn, uint16_t type); 80 int L2capSendInformationRsp(const L2capConnection *conn, uint8_t ident, uint16_t infoType); 81 82 int L2capSendSFrame(const L2capConnection *conn, L2capChannel *chan, uint8_t pBit, uint8_t fBit, uint8_t sBit); 83 int L2capSendIFrame(L2capConnection *conn, L2capChannel *chan, Packet *pkt); 84 85 void L2capErfcStartRetransmissionTimer(L2capChannel *chan); 86 void L2capErfcStartMonitorTimer(L2capChannel *chan); 87 88 #ifdef __cplusplus 89 } 90 #endif // __cplusplus 91 92 #endif // L2CAP_CORE_H 93