The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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 definitions internal to the RFC unit |
| 22 | * |
| 23 | *****************************************************************************/ |
| 24 | |
| 25 | #ifndef RFC_INT_H |
| 26 | #define RFC_INT_H |
| 27 | |
| 28 | #include "l2c_api.h" |
| 29 | #include "port_int.h" |
| 30 | |
| 31 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 32 | * Define RFCOMM result codes |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 33 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 34 | #define RFCOMM_SUCCESS 0 |
| 35 | #define RFCOMM_ERROR 1 |
| 36 | #define RFCOMM_LOW_RESOURCES 2 |
| 37 | #define RFCOMM_TRY_LATER 3 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 38 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 39 | #define RFCOMM_USER_ERR 111 |
| 40 | #define RFCOMM_SECURITY_ERR 112 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 41 | |
| 42 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 43 | * Define max and min RFCOMM MTU (N1) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 44 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 45 | #define RFCOMM_MIN_MTU 23 |
| 46 | #define RFCOMM_MAX_MTU 32767 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 47 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 48 | extern void RFCOMM_StartReq(tRFC_MCB* p_mcb); |
| 49 | extern void RFCOMM_StartRsp(tRFC_MCB* p_mcb, uint16_t result); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 50 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 51 | extern void RFCOMM_DlcEstablishReq(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu); |
| 52 | extern void RFCOMM_DlcEstablishRsp(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, |
| 53 | uint16_t result); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 54 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 55 | extern void RFCOMM_DataReq(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 56 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 57 | extern void RFCOMM_DlcReleaseReq(tRFC_MCB* p_mcb, uint8_t dlci); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 58 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 59 | extern void RFCOMM_ParNegReq(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu); |
| 60 | extern void RFCOMM_ParNegRsp(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, |
| 61 | uint8_t cl, uint8_t k); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 62 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 63 | extern void RFCOMM_TestReq(uint8_t* p_data, uint16_t len); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 64 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 65 | #define RFCOMM_FLOW_STATE_DISABLE 0 |
| 66 | #define RFCOMM_FLOW_STATE_ENABLE 1 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 67 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 68 | extern void RFCOMM_FlowReq(tRFC_MCB* p_mcb, uint8_t dlci, uint8_t state); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 69 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 70 | extern void RFCOMM_PortNegReq(tRFC_MCB* p_mcb, uint8_t dlci, |
| 71 | tPORT_STATE* p_pars); |
| 72 | extern void RFCOMM_PortNegRsp(tRFC_MCB* p_mcb, uint8_t dlci, |
| 73 | tPORT_STATE* p_pars, uint16_t param_mask); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 74 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 75 | extern void RFCOMM_ControlReq(tRFC_MCB* p_mcb, uint8_t dlci, |
| 76 | tPORT_CTRL* p_pars); |
| 77 | extern void RFCOMM_ControlRsp(tRFC_MCB* p_mcb, uint8_t dlci, |
| 78 | tPORT_CTRL* p_pars); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 79 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 80 | extern void RFCOMM_LineStatusReq(tRFC_MCB* p_mcb, uint8_t dlci, |
| 81 | uint8_t line_status); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 82 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 83 | * Define logical struct used for sending and decoding MX frames |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 84 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 85 | typedef struct { |
| 86 | uint8_t dlci; |
| 87 | uint8_t type; |
| 88 | uint8_t cr; |
| 89 | uint8_t ea; |
| 90 | uint8_t pf; |
| 91 | uint8_t credit; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 92 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 93 | union { |
| 94 | struct { |
| 95 | uint8_t dlci; |
| 96 | uint8_t frame_type; |
| 97 | uint8_t conv_layer; |
| 98 | uint8_t priority; |
| 99 | uint8_t t1; |
| 100 | uint16_t mtu; |
| 101 | uint8_t n2; |
| 102 | uint8_t k; |
| 103 | } pn; |
| 104 | struct { |
| 105 | uint8_t* p_data; |
| 106 | uint16_t data_len; |
| 107 | } test; |
| 108 | struct { |
| 109 | uint8_t dlci; |
| 110 | uint8_t signals; |
| 111 | uint8_t break_present; |
| 112 | uint8_t break_duration; |
| 113 | } msc; |
| 114 | struct { |
| 115 | uint8_t ea; |
| 116 | uint8_t cr; |
| 117 | uint8_t type; |
| 118 | } nsc; |
| 119 | struct { |
| 120 | uint8_t dlci; |
| 121 | uint8_t is_request; |
| 122 | uint8_t baud_rate; |
| 123 | uint8_t byte_size; |
| 124 | uint8_t stop_bits; |
| 125 | uint8_t parity; |
| 126 | uint8_t parity_type; |
| 127 | uint8_t fc_type; |
| 128 | uint8_t xon_char; |
| 129 | uint8_t xoff_char; |
| 130 | uint16_t param_mask; |
| 131 | } rpn; |
| 132 | struct { |
| 133 | uint8_t dlci; |
| 134 | uint8_t line_status; |
| 135 | } rls; |
| 136 | } u; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 137 | } MX_FRAME; |
| 138 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 139 | #define LINE_STATUS_NO_ERROR 0x00 |
| 140 | #define LINE_STATUS_OVERRUN 0x02 /* Receive Overrun Error */ |
| 141 | #define LINE_STATUS_RXPARITY 0x04 /* Receive Parity Error */ |
| 142 | #define LINE_STATUS_FRAME 0x08 /* Receive Framing error */ |
| 143 | #define LINE_STATUS_FAILED 0x10 /* Connection Failed */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 144 | |
| 145 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 146 | * Define states and events for the RFC multiplexer state machine |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 147 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 148 | #define RFC_MX_STATE_IDLE 0 |
| 149 | #define RFC_MX_STATE_WAIT_CONN_CNF 1 |
| 150 | #define RFC_MX_STATE_CONFIGURE 2 |
| 151 | #define RFC_MX_STATE_SABME_WAIT_UA 3 |
| 152 | #define RFC_MX_STATE_WAIT_SABME 4 |
| 153 | #define RFC_MX_STATE_CONNECTED 5 |
| 154 | #define RFC_MX_STATE_DISC_WAIT_UA 6 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 155 | |
| 156 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 157 | * Define port states |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 158 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 159 | #define RFC_STATE_CLOSED 0 |
| 160 | #define RFC_STATE_SABME_WAIT_UA 1 |
| 161 | #define RFC_STATE_ORIG_WAIT_SEC_CHECK 2 |
| 162 | #define RFC_STATE_TERM_WAIT_SEC_CHECK 3 |
| 163 | #define RFC_STATE_OPENED 4 |
| 164 | #define RFC_STATE_DISC_WAIT_UA 5 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 165 | |
| 166 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 167 | * Events that can be received by multiplexer as well as port state machines |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 168 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 169 | #define RFC_EVENT_SABME 0 |
| 170 | #define RFC_EVENT_UA 1 |
| 171 | #define RFC_EVENT_DM 2 |
| 172 | #define RFC_EVENT_DISC 3 |
| 173 | #define RFC_EVENT_UIH 4 |
| 174 | #define RFC_EVENT_TIMEOUT 5 |
| 175 | #define RFC_EVENT_BAD_FRAME 50 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 176 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 177 | * Multiplexer events |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 178 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 179 | #define RFC_MX_EVENT_START_REQ 6 |
| 180 | #define RFC_MX_EVENT_START_RSP 7 |
| 181 | #define RFC_MX_EVENT_CLOSE_REQ 8 |
| 182 | #define RFC_MX_EVENT_CONN_CNF 9 |
| 183 | #define RFC_MX_EVENT_CONN_IND 10 |
| 184 | #define RFC_MX_EVENT_CONF_CNF 11 |
| 185 | #define RFC_MX_EVENT_CONF_IND 12 |
| 186 | #define RFC_MX_EVENT_QOS_VIOLATION_IND 13 |
| 187 | #define RFC_MX_EVENT_DISC_IND 14 |
| 188 | #define RFC_MX_EVENT_TEST_CMD 15 |
| 189 | #define RFC_MX_EVENT_TEST_RSP 16 |
| 190 | #define RFC_MX_EVENT_FCON_CMD 17 |
| 191 | #define RFC_MX_EVENT_FCOFF_CMD 18 |
| 192 | #define RFC_MX_EVENT_NSC 19 |
| 193 | #define RFC_MX_EVENT_NSC_RSP 20 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 194 | |
| 195 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 196 | * Port events |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 197 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 198 | #define RFC_EVENT_OPEN 9 |
| 199 | #define RFC_EVENT_ESTABLISH_RSP 11 |
| 200 | #define RFC_EVENT_CLOSE 12 |
| 201 | #define RFC_EVENT_CLEAR 13 |
| 202 | #define RFC_EVENT_DATA 14 |
| 203 | #define RFC_EVENT_SEC_COMPLETE 15 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 204 | |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 205 | /* seconds to wait for reply with Poll bit */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 206 | #define RFC_T1_TIMEOUT 20 |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 207 | /* seconds to wait for reply with Poll bit other than MX */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 208 | #define RFC_PORT_T1_TIMEOUT 60 |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 209 | /* timeout to wait for Mx UIH */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 210 | #define RFC_T2_TIMEOUT 20 |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 211 | /* If something goes wrong and we send DISC we should not wait for min */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 212 | #define RFC_DISC_TIMEOUT 3 |
| 213 | #define RFC_CLOSE_TIMEOUT 10 |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 214 | /* first connection to be established on Mx */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 215 | #define RFCOMM_CONN_TIMEOUT 120 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 216 | |
| 217 | /* Define RFComm control block |
| 218 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 219 | typedef struct { |
| 220 | MX_FRAME rx_frame; |
| 221 | tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */ |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 222 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 223 | /* MCB based on the L2CAP's lcid */ |
| 224 | tRFC_MCB* p_rfc_lcid_mcb[MAX_L2CAP_CHANNELS]; |
| 225 | bool peer_rx_disabled; /* If true peer sent FCOFF */ |
| 226 | uint8_t last_mux; /* Last mux allocated */ |
| 227 | uint8_t last_port; /* Last port allocated */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 228 | } tRFCOMM_CB; |
| 229 | |
| 230 | /* Main Control Block for the RFCOMM Layer (PORT and RFC) */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 231 | typedef struct { |
| 232 | tRFCOMM_CB rfc; |
| 233 | tPORT_CB port; |
| 234 | uint8_t trace_level; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 235 | } tRFC_CB; |
| 236 | |
Pavlin Radoslavov | 37c1b5f | 2016-10-14 15:47:27 -0700 | [diff] [blame] | 237 | extern tRFC_CB rfc_cb; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 238 | |
Myles Watson | 9ca0709 | 2016-11-28 16:41:53 -0800 | [diff] [blame] | 239 | /* Timer running on the multiplexor channel while no DLCI connection is open */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 240 | #define RFC_MCB_INIT_INACT_TIMER 60 /* in seconds */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 241 | |
| 242 | /* Timer running on the multiplexor channel after last DLCI is released */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 243 | #define RFC_MCB_RELEASE_INACT_TIMER 2 /* in seconds */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 244 | |
| 245 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 246 | * Define RFCOMM frame processing errors |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 247 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 248 | #define RFCOMM_ERR_BAD_SABME 1 |
| 249 | #define RFCOMM_ERR_BAD_UA 2 |
| 250 | #define RFCOMM_ERR_BAD_DM 3 |
| 251 | #define RFCOMM_ERR_BAD_DISC 4 |
| 252 | #define RFCOMM_ERR_BAD_UIH 5 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 253 | |
| 254 | #ifdef RFCOMM_PRECALC_FCS |
| 255 | |
| 256 | #define RFCOMM_SABME_FCS(p_data, cr, dlci) rfc_sabme_fcs[cr][dlci] |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 257 | #define RFCOMM_UA_FCS(p_data, cr, dlci) rfc_ua_fcs[cr][dlci] |
| 258 | #define RFCOMM_DM_FCS(p_data, cr, dlci) rfc_dm_fcs[cr][dlci] |
| 259 | #define RFCOMM_DISC_FCS(p_data, cr, dlci) rfc_disc_fcs[cr][dlci] |
| 260 | #define RFCOMM_UIH_FCS(p_data, dlci) rfc_uih_fcs[dlci] |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 261 | |
| 262 | #else |
| 263 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 264 | extern uint8_t rfc_calc_fcs(uint16_t len, uint8_t* p); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 265 | |
| 266 | #define RFCOMM_SABME_FCS(p_data, cr, dlci) rfc_calc_fcs(3, p_data) |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 267 | #define RFCOMM_UA_FCS(p_data, cr, dlci) rfc_calc_fcs(3, p_data) |
| 268 | #define RFCOMM_DM_FCS(p_data, cr, dlci) rfc_calc_fcs(3, p_data) |
| 269 | #define RFCOMM_DISC_FCS(p_data, cr, dlci) rfc_calc_fcs(3, p_data) |
| 270 | #define RFCOMM_UIH_FCS(p_data, dlci) rfc_calc_fcs(2, p_data) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 271 | |
| 272 | #endif |
| 273 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 274 | extern void rfc_mx_sm_execute(tRFC_MCB* p_mcb, uint16_t event, void* p_data); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 275 | |
| 276 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 277 | * Functions provided by the rfc_port_fsm.cc |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 278 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 279 | extern void rfc_port_sm_execute(tPORT* p_port, uint16_t event, void* p_data); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 280 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 281 | extern void rfc_process_pn(tRFC_MCB* p_rfc_mcb, bool is_command, |
| 282 | MX_FRAME* p_frame); |
| 283 | extern void rfc_process_msc(tRFC_MCB* p_rfc_mcb, bool is_command, |
| 284 | MX_FRAME* p_frame); |
| 285 | extern void rfc_process_rpn(tRFC_MCB* p_rfc_mcb, bool is_command, |
| 286 | bool is_request, MX_FRAME* p_frame); |
| 287 | extern void rfc_process_rls(tRFC_MCB* p_rfc_mcb, bool is_command, |
| 288 | MX_FRAME* p_frame); |
| 289 | extern void rfc_process_nsc(tRFC_MCB* p_rfc_mcb, MX_FRAME* p_frame); |
| 290 | extern void rfc_process_test_rsp(tRFC_MCB* p_rfc_mcb, BT_HDR* p_buf); |
| 291 | extern void rfc_process_fcon(tRFC_MCB* p_rfc_mcb, bool is_command); |
| 292 | extern void rfc_process_fcoff(tRFC_MCB* p_rfc_mcb, bool is_command); |
| 293 | extern void rfc_process_l2cap_congestion(tRFC_MCB* p_mcb, bool is_congested); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 294 | |
| 295 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 296 | * Functions provided by the rfc_utils.cc |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 297 | */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame^] | 298 | tRFC_MCB* rfc_alloc_multiplexer_channel(const RawAddress& bd_addr, |
Jakub Pawlowski | 1979fa3 | 2017-06-16 10:46:47 -0700 | [diff] [blame] | 299 | bool is_initiator); |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 300 | extern void rfc_release_multiplexer_channel(tRFC_MCB* p_rfc_mcb); |
| 301 | extern void rfc_timer_start(tRFC_MCB* p_rfc_mcb, uint16_t timeout); |
| 302 | extern void rfc_timer_stop(tRFC_MCB* p_rfc_mcb); |
| 303 | extern void rfc_port_timer_start(tPORT* p_port, uint16_t tout); |
| 304 | extern void rfc_port_timer_stop(tPORT* p_port); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 305 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 306 | bool rfc_check_uih_fcs(uint8_t dlci, uint8_t received_fcs); |
| 307 | bool rfc_check_fcs(uint16_t len, uint8_t* p, uint8_t received_fcs); |
| 308 | tRFC_MCB* rfc_find_lcid_mcb(uint16_t lcid); |
| 309 | extern void rfc_save_lcid_mcb(tRFC_MCB* p_rfc_mcb, uint16_t lcid); |
| 310 | extern void rfc_check_mcb_active(tRFC_MCB* p_mcb); |
| 311 | extern void rfc_port_closed(tPORT* p_port); |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame^] | 312 | extern void rfc_sec_check_complete(const RawAddress* bd_addr, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 313 | tBT_TRANSPORT transport, void* p_ref_data, |
| 314 | uint8_t res); |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 315 | extern void rfc_inc_credit(tPORT* p_port, uint8_t credit); |
| 316 | extern void rfc_dec_credit(tPORT* p_port); |
| 317 | extern void rfc_check_send_cmd(tRFC_MCB* p_mcb, BT_HDR* p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 318 | |
| 319 | /* |
Myles Watson | ee96a3c | 2016-11-23 14:49:54 -0800 | [diff] [blame] | 320 | * Functions provided by the rfc_ts_frames.cc |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 321 | */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 322 | extern void rfc_send_sabme(tRFC_MCB* p_rfc_mcb, uint8_t dlci); |
| 323 | extern void rfc_send_ua(tRFC_MCB* p_rfc_mcb, uint8_t dlci); |
| 324 | extern void rfc_send_dm(tRFC_MCB* p_rfc_mcb, uint8_t dlci, bool pf); |
| 325 | extern void rfc_send_disc(tRFC_MCB* p_rfc_mcb, uint8_t dlci); |
| 326 | extern void rfc_send_pn(tRFC_MCB* p_mcb, uint8_t dlci, bool is_command, |
| 327 | uint16_t mtu, uint8_t cl, uint8_t k); |
| 328 | extern void rfc_send_test(tRFC_MCB* p_rfc_mcb, bool is_command, BT_HDR* p_buf); |
| 329 | extern void rfc_send_msc(tRFC_MCB* p_mcb, uint8_t dlci, bool is_command, |
| 330 | tPORT_CTRL* p_pars); |
| 331 | extern void rfc_send_rls(tRFC_MCB* p_mcb, uint8_t dlci, bool is_command, |
| 332 | uint8_t status); |
| 333 | extern void rfc_send_rpn(tRFC_MCB* p_mcb, uint8_t dlci, bool is_command, |
| 334 | tPORT_STATE* p_pars, uint16_t mask); |
| 335 | extern void rfc_send_fcon(tRFC_MCB* p_mcb, bool is_command); |
| 336 | extern void rfc_send_fcoff(tRFC_MCB* p_mcb, bool is_command); |
| 337 | extern void rfc_send_buf_uih(tRFC_MCB* p_rfc_mcb, uint8_t dlci, BT_HDR* p_buf); |
| 338 | extern void rfc_send_credit(tRFC_MCB* p_mcb, uint8_t dlci, uint8_t credit); |
| 339 | extern void rfc_process_mx_message(tRFC_MCB* p_rfc_mcb, BT_HDR* p_buf); |
| 340 | extern uint8_t rfc_parse_data(tRFC_MCB* p_rfc_mcb, MX_FRAME* p_frame, |
| 341 | BT_HDR* p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 342 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 343 | /* Call back functions from RFCOMM */ |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 344 | extern void rfcomm_l2cap_if_init(void); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 345 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 346 | extern void PORT_StartInd(tRFC_MCB* p_mcb); |
| 347 | extern void PORT_StartCnf(tRFC_MCB* p_mcb, uint16_t result); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 348 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 349 | extern void PORT_CloseInd(tRFC_MCB* p_mcb); |
| 350 | extern void Port_TimeOutCloseMux(tRFC_MCB* p_mcb); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 351 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 352 | extern void PORT_DlcEstablishInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu); |
| 353 | extern void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, |
| 354 | uint16_t result); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 355 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 356 | extern void PORT_DataInd(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 357 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 358 | extern void PORT_DlcReleaseInd(tRFC_MCB* p_mcb, uint8_t dlci); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 359 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 360 | extern void PORT_ParNegInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, |
| 361 | uint8_t cl, uint8_t k); |
| 362 | extern void PORT_ParNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, |
| 363 | uint8_t cl, uint8_t k); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 364 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 365 | extern void PORT_TestCnf(tRFC_MCB* p_mcb, uint8_t* p_data, uint16_t len); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 366 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 367 | extern void PORT_FlowInd(tRFC_MCB* p_mcb, uint8_t dlci, bool fc); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 368 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 369 | extern void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, |
| 370 | uint16_t param_mask); |
| 371 | extern void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, |
| 372 | uint16_t result); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 373 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 374 | extern void PORT_ControlInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_CTRL* p_pars); |
| 375 | extern void PORT_ControlCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_CTRL* p_pars); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 376 | |
Myles Watson | 911d1ae | 2016-11-28 16:44:40 -0800 | [diff] [blame] | 377 | extern void PORT_LineStatusInd(tRFC_MCB* p_mcb, uint8_t dlci, |
| 378 | uint8_t line_status); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 379 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 380 | #endif |