1 /******************************************************************************
2 *
3 * Copyright 2004-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 pan action functions for the state machine.
22 *
23 ******************************************************************************/
24
25 #define LOG_TAG "bluetooth"
26
27 #include <cstdint>
28
29 // PAN_INCLUDED
30 #include "bt_target.h" // Must be first to define build configuration
31 #if (PAN_INCLUDED == TRUE)
32
33 #include "bta/include/bta_pan_co.h"
34 #include "bta/pan/bta_pan_int.h"
35 #include "main/shim/dumpsys.h"
36 #include "osi/include/allocator.h"
37 #include "osi/include/fixed_queue.h"
38 #include "osi/include/log.h"
39 #include "osi/include/osi.h" // UNUSED_ATTR
40 #include "stack/include/bt_hdr.h"
41 #include "stack/include/bt_types.h"
42 #include "stack/include/btu.h"
43 #include "stack/include/pan_api.h"
44 #include "types/raw_address.h"
45
46 void bta_pan_sm_execute(tBTA_PAN_SCB* p_scb, uint16_t event,
47 tBTA_PAN_DATA* p_data);
48
49 /* RX and TX data flow mask */
50 #define BTA_PAN_RX_MASK 0x0F
51 #define BTA_PAN_TX_MASK 0xF0
52
53 /*******************************************************************************
54 *
55 * Function bta_pan_pm_conn_busy
56 *
57 * Description set pan pm connection busy state
58 *
59 * Params p_scb: state machine control block of pan connection
60 *
61 * Returns void
62 *
63 ******************************************************************************/
bta_pan_pm_conn_busy(tBTA_PAN_SCB * p_scb)64 static void bta_pan_pm_conn_busy(tBTA_PAN_SCB* p_scb) {
65 if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
66 bta_sys_busy(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
67 }
68
69 /*******************************************************************************
70 *
71 * Function bta_pan_pm_conn_idle
72 *
73 * Description set pan pm connection idle state
74 *
75 * Params p_scb: state machine control block of pan connection
76 *
77 * Returns void
78 *
79 ******************************************************************************/
bta_pan_pm_conn_idle(tBTA_PAN_SCB * p_scb)80 static void bta_pan_pm_conn_idle(tBTA_PAN_SCB* p_scb) {
81 if ((p_scb != NULL) && (p_scb->state != BTA_PAN_IDLE_ST))
82 bta_sys_idle(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
83 }
84
85 /*******************************************************************************
86 *
87 * Function bta_pan_conn_state_cback
88 *
89 * Description Connection state callback from Pan profile
90 *
91 *
92 * Returns void
93 *
94 ******************************************************************************/
bta_pan_conn_state_cback(uint16_t handle,const RawAddress & bd_addr,tPAN_RESULT state,bool is_role_change,uint8_t src_role,uint8_t dst_role)95 static void bta_pan_conn_state_cback(uint16_t handle, const RawAddress& bd_addr,
96 tPAN_RESULT state, bool is_role_change,
97 uint8_t src_role, uint8_t dst_role) {
98 tBTA_PAN_SCB* p_scb;
99 tBTA_PAN_CONN* p_buf = (tBTA_PAN_CONN*)osi_malloc(sizeof(tBTA_PAN_CONN));
100
101 if ((state == PAN_SUCCESS) && !is_role_change) {
102 p_buf->hdr.event = BTA_PAN_CONN_OPEN_EVT;
103 p_scb = bta_pan_scb_by_handle(handle);
104 if (p_scb == NULL) {
105 /* allocate an scb */
106 p_scb = bta_pan_scb_alloc();
107 }
108 /* we have exceeded maximum number of connections */
109 if (!p_scb) {
110 PAN_Disconnect(handle);
111 return;
112 }
113
114 p_scb->handle = handle;
115 p_scb->local_role = src_role;
116 p_scb->peer_role = dst_role;
117 p_scb->pan_flow_enable = true;
118 p_scb->bd_addr = bd_addr;
119 p_scb->data_queue = fixed_queue_new(SIZE_MAX);
120
121 if (src_role == PAN_ROLE_CLIENT)
122 p_scb->app_id = bta_pan_cb.app_id[0];
123 else if (src_role == PAN_ROLE_NAP_SERVER)
124 p_scb->app_id = bta_pan_cb.app_id[2];
125 } else if ((state != PAN_SUCCESS) && !is_role_change) {
126 p_buf->hdr.event = BTA_PAN_CONN_CLOSE_EVT;
127 } else {
128 return;
129 }
130
131 p_buf->result = state;
132 p_buf->hdr.layer_specific = handle;
133
134 bta_sys_sendmsg(p_buf);
135 }
136
137 /*******************************************************************************
138 *
139 * Function bta_pan_data_flow_cb
140 *
141 * Description Data flow status callback from PAN
142 *
143 *
144 * Returns void
145 *
146 ******************************************************************************/
bta_pan_data_flow_cb(uint16_t handle,tPAN_RESULT result)147 static void bta_pan_data_flow_cb(uint16_t handle, tPAN_RESULT result) {
148 tBTA_PAN_SCB* p_scb;
149
150 p_scb = bta_pan_scb_by_handle(handle);
151 if (p_scb == NULL) return;
152
153 if (result == PAN_TX_FLOW_ON) {
154 BT_HDR_RIGID* p_buf = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID));
155 p_buf->layer_specific = handle;
156 p_buf->event = BTA_PAN_BNEP_FLOW_ENABLE_EVT;
157 bta_sys_sendmsg(p_buf);
158 bta_pan_co_rx_flow(handle, p_scb->app_id, true);
159 } else if (result == PAN_TX_FLOW_OFF) {
160 p_scb->pan_flow_enable = false;
161 bta_pan_co_rx_flow(handle, p_scb->app_id, false);
162 }
163 }
164
165 /*******************************************************************************
166 *
167 * Function bta_pan_data_buf_ind_cback
168 *
169 * Description data indication callback from pan profile
170 *
171 *
172 * Returns void
173 *
174 ******************************************************************************/
bta_pan_data_buf_ind_cback(uint16_t handle,const RawAddress & src,const RawAddress & dst,uint16_t protocol,BT_HDR * p_buf,bool ext,bool forward)175 static void bta_pan_data_buf_ind_cback(uint16_t handle, const RawAddress& src,
176 const RawAddress& dst, uint16_t protocol,
177 BT_HDR* p_buf, bool ext, bool forward) {
178 tBTA_PAN_SCB* p_scb = bta_pan_scb_by_handle(handle);
179 if (p_scb == NULL) {
180 return;
181 }
182
183 if (sizeof(BT_HDR) + sizeof(tBTA_PAN_DATA_PARAMS) + p_buf->len >
184 PAN_BUF_SIZE) {
185 APPL_TRACE_ERROR("%s: received buffer length too large: %d", __func__,
186 p_buf->len);
187 return;
188 }
189
190 BT_HDR* p_new_buf = (BT_HDR*)osi_malloc(PAN_BUF_SIZE);
191 memcpy((uint8_t*)(p_new_buf + 1) + sizeof(tBTA_PAN_DATA_PARAMS),
192 (uint8_t*)(p_buf + 1) + p_buf->offset, p_buf->len);
193 p_new_buf->len = p_buf->len;
194 p_new_buf->offset = sizeof(tBTA_PAN_DATA_PARAMS);
195
196 /* copy params into the space before the data */
197 ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->src = src;
198 ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->dst = dst;
199 ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->protocol = protocol;
200 ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->ext = ext;
201 ((tBTA_PAN_DATA_PARAMS*)p_new_buf)->forward = forward;
202
203 fixed_queue_enqueue(p_scb->data_queue, p_new_buf);
204 BT_HDR_RIGID* p_event = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID));
205 p_event->layer_specific = handle;
206 p_event->event = BTA_PAN_RX_FROM_BNEP_READY_EVT;
207 bta_sys_sendmsg(p_event);
208 }
209
210 /*******************************************************************************
211 *
212 * Function bta_pan_pfilt_ind_cback
213 *
214 * Description
215 *
216 *
217 * Returns void
218 *
219 ******************************************************************************/
bta_pan_pfilt_ind_cback(uint16_t handle,bool indication,tPAN_RESULT result,uint16_t num_filters,uint8_t * p_filters)220 static void bta_pan_pfilt_ind_cback(uint16_t handle, bool indication,
221 tPAN_RESULT result, uint16_t num_filters,
222 uint8_t* p_filters) {
223 bta_pan_co_pfilt_ind(handle, indication,
224 (result == PAN_SUCCESS) ? BTA_PAN_SUCCESS : BTA_PAN_FAIL,
225 num_filters, p_filters);
226 }
227
228 /*******************************************************************************
229 *
230 * Function bta_pan_mfilt_ind_cback
231 *
232 * Description
233 *
234 *
235 * Returns void
236 *
237 ******************************************************************************/
bta_pan_mfilt_ind_cback(uint16_t handle,bool indication,tPAN_RESULT result,uint16_t num_mfilters,uint8_t * p_mfilters)238 static void bta_pan_mfilt_ind_cback(uint16_t handle, bool indication,
239 tPAN_RESULT result, uint16_t num_mfilters,
240 uint8_t* p_mfilters) {
241 bta_pan_co_mfilt_ind(handle, indication,
242 (result == PAN_SUCCESS) ? BTA_PAN_SUCCESS : BTA_PAN_FAIL,
243 num_mfilters, p_mfilters);
244 }
245
246 /*******************************************************************************
247 *
248 * Function bta_pan_has_multiple_connections
249 *
250 * Description Check whether there are multiple GN/NAP connections to
251 * different devices
252 *
253 *
254 * Returns bool
255 *
256 ******************************************************************************/
bta_pan_has_multiple_connections(uint8_t app_id)257 static bool bta_pan_has_multiple_connections(uint8_t app_id) {
258 tBTA_PAN_SCB* p_scb = NULL;
259 bool found = false;
260 RawAddress bd_addr;
261
262 for (uint8_t index = 0; index < BTA_PAN_NUM_CONN; index++) {
263 p_scb = &bta_pan_cb.scb[index];
264 if (p_scb->in_use && app_id == p_scb->app_id) {
265 /* save temp bd_addr */
266 bd_addr = p_scb->bd_addr;
267 found = true;
268 break;
269 }
270 }
271
272 /* If cannot find a match then there is no connection at all */
273 if (!found) return false;
274
275 /* Find whether there is another connection with different device other than
276 PANU.
277 Could be same service or different service */
278 for (uint8_t index = 0; index < BTA_PAN_NUM_CONN; index++) {
279 p_scb = &bta_pan_cb.scb[index];
280 if (p_scb->in_use && p_scb->app_id != bta_pan_cb.app_id[0] &&
281 bd_addr != p_scb->bd_addr) {
282 return true;
283 }
284 }
285 return false;
286 }
287
288 /*******************************************************************************
289 *
290 * Function bta_pan_enable
291 *
292 * Description
293 *
294 *
295 *
296 * Returns void
297 *
298 ******************************************************************************/
bta_pan_enable(tBTA_PAN_DATA * p_data)299 void bta_pan_enable(tBTA_PAN_DATA* p_data) {
300 tPAN_REGISTER reg_data;
301
302 bta_pan_cb.p_cback = p_data->api_enable.p_cback;
303
304 reg_data.pan_conn_state_cb = bta_pan_conn_state_cback;
305 reg_data.pan_bridge_req_cb = NULL;
306 reg_data.pan_data_buf_ind_cb = bta_pan_data_buf_ind_cback;
307 reg_data.pan_data_ind_cb = NULL;
308 reg_data.pan_pfilt_ind_cb = bta_pan_pfilt_ind_cback;
309 reg_data.pan_mfilt_ind_cb = bta_pan_mfilt_ind_cback;
310 reg_data.pan_tx_data_flow_cb = bta_pan_data_flow_cb;
311
312 PAN_Register(®_data);
313
314 bta_pan_cb.flow_mask = bta_pan_co_init(&bta_pan_cb.q_level);
315 bta_pan_cb.p_cback(BTA_PAN_ENABLE_EVT, NULL);
316 }
317
318 /*******************************************************************************
319 *
320 * Function bta_pan_set_role
321 *
322 * Description
323 *
324 * Returns void
325 *
326 ******************************************************************************/
bta_pan_set_role(tBTA_PAN_DATA * p_data)327 void bta_pan_set_role(tBTA_PAN_DATA* p_data) {
328 bta_pan_cb.app_id[0] = p_data->api_set_role.user_app_id;
329 bta_pan_cb.app_id[2] = p_data->api_set_role.nap_app_id;
330
331 /* set security correctly in api and here */
332 tPAN_RESULT status = PAN_SetRole(p_data->api_set_role.role,
333 std::string(p_data->api_set_role.user_name),
334 std::string(p_data->api_set_role.nap_name));
335
336 tBTA_PAN bta_pan = {
337 .set_role =
338 {
339 .role = p_data->api_set_role.role,
340 .status =
341 (status == PAN_SUCCESS) ? BTA_PAN_SUCCESS : BTA_PAN_FAIL,
342 },
343 };
344
345 if (status == PAN_SUCCESS) {
346 if (p_data->api_set_role.role & PAN_ROLE_NAP_SERVER)
347 bta_sys_add_uuid(UUID_SERVCLASS_NAP);
348 else
349 bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
350
351 if (p_data->api_set_role.role & PAN_ROLE_CLIENT)
352 bta_sys_add_uuid(UUID_SERVCLASS_PANU);
353 else
354 bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
355 }
356 /* if status is not success clear everything */
357 else {
358 PAN_SetRole(0, std::string(), std::string());
359 bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
360 bta_sys_remove_uuid(UUID_SERVCLASS_GN);
361 bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
362 }
363 bta_pan_cb.p_cback(BTA_PAN_SET_ROLE_EVT, &bta_pan);
364 }
365
366 /*******************************************************************************
367 *
368 * Function bta_pan_disable
369 *
370 * Description
371 *
372 *
373 *
374 * Returns void
375 *
376 ******************************************************************************/
bta_pan_disable(void)377 void bta_pan_disable(void) {
378 BT_HDR* p_buf;
379 tBTA_PAN_SCB* p_scb = &bta_pan_cb.scb[0];
380 uint8_t i;
381
382 /* close all connections */
383 PAN_SetRole(0, std::string(), std::string());
384
385 #if (BTA_EIR_CANNED_UUID_LIST != TRUE)
386 bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
387 bta_sys_remove_uuid(UUID_SERVCLASS_GN);
388 bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
389 #endif // BTA_EIR_CANNED_UUID_LIST
390 /* free all queued up data buffers */
391 for (i = 0; i < BTA_PAN_NUM_CONN; i++, p_scb++) {
392 if (p_scb->in_use) {
393 while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_scb->data_queue)) !=
394 NULL)
395 osi_free(p_buf);
396
397 bta_pan_co_close(p_scb->handle, p_scb->app_id);
398 }
399 }
400
401 PAN_Deregister();
402 }
403
404 /*******************************************************************************
405 *
406 * Function bta_pan_open
407 *
408 * Description
409 *
410 * Returns void
411 *
412 ******************************************************************************/
bta_pan_open(tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)413 void bta_pan_open(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
414 tPAN_RESULT status;
415 tBTA_PAN bta_pan;
416
417 status = PAN_Connect(p_data->api_open.bd_addr, p_data->api_open.local_role,
418 p_data->api_open.peer_role, &p_scb->handle);
419 APPL_TRACE_DEBUG("%s pan connect status: %d", __func__, status);
420
421 if (status == PAN_SUCCESS) {
422 p_scb->bd_addr = p_data->api_open.bd_addr;
423 p_scb->local_role = p_data->api_open.local_role;
424 p_scb->peer_role = p_data->api_open.peer_role;
425 bta_pan.opening.bd_addr = p_data->api_open.bd_addr;
426 bta_pan.opening.handle = p_scb->handle;
427 bta_pan_cb.p_cback(BTA_PAN_OPENING_EVT, &bta_pan);
428
429 } else {
430 bta_pan_scb_dealloc(p_scb);
431 bta_pan.open.bd_addr = p_data->api_open.bd_addr;
432 bta_pan.open.status = BTA_PAN_FAIL;
433 bta_pan.open.local_role = p_data->api_open.local_role;
434 bta_pan.open.peer_role = p_data->api_open.peer_role;
435 bta_pan_cb.p_cback(BTA_PAN_OPEN_EVT, &bta_pan);
436 }
437 }
438
439 /*******************************************************************************
440 *
441 * Function bta_pan_close
442 *
443 * Description
444 *
445 *
446 *
447 * Returns void
448 *
449 ******************************************************************************/
bta_pan_api_close(tBTA_PAN_SCB * p_scb,UNUSED_ATTR tBTA_PAN_DATA * p_data)450 void bta_pan_api_close(tBTA_PAN_SCB* p_scb, UNUSED_ATTR tBTA_PAN_DATA* p_data) {
451 tBTA_PAN_CONN* p_buf = (tBTA_PAN_CONN*)osi_malloc(sizeof(tBTA_PAN_CONN));
452
453 PAN_Disconnect(p_scb->handle);
454
455 /*
456 * Send an event to BTA so that application will get the connection
457 * close event.
458 */
459 p_buf->hdr.event = BTA_PAN_CONN_CLOSE_EVT;
460 p_buf->hdr.layer_specific = p_scb->handle;
461
462 bta_sys_sendmsg(p_buf);
463 }
464
465 /*******************************************************************************
466 *
467 * Function bta_pan_conn_open
468 *
469 * Description process connection open event
470 *
471 * Returns void
472 *
473 ******************************************************************************/
bta_pan_conn_open(tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)474 void bta_pan_conn_open(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
475 tBTA_PAN bta_pan;
476
477 APPL_TRACE_DEBUG("%s pan connection result: %d", __func__,
478 p_data->conn.result);
479
480 bta_pan.open.bd_addr = p_scb->bd_addr;
481 bta_pan.open.handle = p_scb->handle;
482 bta_pan.open.local_role = p_scb->local_role;
483 bta_pan.open.peer_role = p_scb->peer_role;
484
485 if (p_data->conn.result == PAN_SUCCESS) {
486 bta_pan.open.status = BTA_PAN_SUCCESS;
487 p_scb->pan_flow_enable = true;
488 p_scb->app_flow_enable = true;
489 bta_sys_conn_open(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
490 } else {
491 bta_pan_scb_dealloc(p_scb);
492 bta_pan.open.status = BTA_PAN_FAIL;
493 }
494
495 p_scb->pan_flow_enable = true;
496 p_scb->app_flow_enable = true;
497
498 /* If app_id is NAP/GN, check whether there are multiple connections.
499 If there are, provide a special app_id to dm to enforce central role only.
500 */
501 if (p_scb->app_id == bta_pan_cb.app_id[2] &&
502 bta_pan_has_multiple_connections(p_scb->app_id)) {
503 p_scb->app_id = BTA_APP_ID_PAN_MULTI;
504 }
505
506 bta_sys_conn_open(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
507 bta_pan_cb.p_cback(BTA_PAN_OPEN_EVT, &bta_pan);
508 }
509
510 /*******************************************************************************
511 *
512 * Function bta_pan_conn_close
513 *
514 * Description process connection close event
515 *
516 *
517 *
518 * Returns void
519 *
520 ******************************************************************************/
bta_pan_conn_close(tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)521 void bta_pan_conn_close(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
522 tBTA_PAN bta_pan;
523 BT_HDR* p_buf;
524
525 bta_pan.close.handle = p_data->hdr.layer_specific;
526
527 bta_sys_conn_close(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);
528
529 /* free all queued up data buffers */
530 while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
531 osi_free(p_buf);
532
533 bta_pan_scb_dealloc(p_scb);
534
535 bta_pan_cb.p_cback(BTA_PAN_CLOSE_EVT, &bta_pan);
536 }
537
538 /*******************************************************************************
539 *
540 * Function bta_pan_rx_path
541 *
542 * Description Handle data on the RX path (data sent from the phone to
543 * BTA).
544 *
545 *
546 * Returns void
547 *
548 ******************************************************************************/
bta_pan_rx_path(tBTA_PAN_SCB * p_scb,UNUSED_ATTR tBTA_PAN_DATA * p_data)549 void bta_pan_rx_path(tBTA_PAN_SCB* p_scb, UNUSED_ATTR tBTA_PAN_DATA* p_data) {
550 /* if data path configured for rx pull */
551 if ((bta_pan_cb.flow_mask & BTA_PAN_RX_MASK) == BTA_PAN_RX_PULL) {
552 /* if we can accept data */
553 if (p_scb->pan_flow_enable) {
554 /* call application callout function for rx path */
555 bta_pan_co_rx_path(p_scb->handle, p_scb->app_id);
556 }
557 }
558 /* else data path configured for rx push */
559 else {
560 }
561 }
562
563 /*******************************************************************************
564 *
565 * Function bta_pan_tx_path
566 *
567 * Description Handle the TX data path (data sent from BTA to the phone).
568 *
569 *
570 * Returns void
571 *
572 ******************************************************************************/
bta_pan_tx_path(tBTA_PAN_SCB * p_scb,UNUSED_ATTR tBTA_PAN_DATA * p_data)573 void bta_pan_tx_path(tBTA_PAN_SCB* p_scb, UNUSED_ATTR tBTA_PAN_DATA* p_data) {
574 bta_pan_pm_conn_busy(p_scb);
575 /* call application callout function for tx path */
576 bta_pan_co_tx_path(p_scb->handle, p_scb->app_id);
577
578 /* free data that exceeds queue level */
579 while (fixed_queue_length(p_scb->data_queue) > bta_pan_cb.q_level) {
580 BT_HDR* p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_scb->data_queue);
581 if (p_buf != nullptr) {
582 osi_free(p_buf);
583 }
584 }
585
586 bta_pan_pm_conn_idle(p_scb);
587 }
588
589 /*******************************************************************************
590 *
591 * Function bta_pan_tx_flow
592 *
593 * Description Set the application flow control state.
594 *
595 *
596 * Returns void
597 *
598 ******************************************************************************/
bta_pan_tx_flow(tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)599 void bta_pan_tx_flow(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
600 p_scb->app_flow_enable = p_data->ci_tx_flow.enable;
601 }
602
603 /*******************************************************************************
604 *
605 * Function bta_pan_write_buf
606 *
607 * Description Handle a bta_pan_ci_rx_writebuf() and send data to PAN.
608 *
609 *
610 * Returns void
611 *
612 ******************************************************************************/
bta_pan_write_buf(tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)613 void bta_pan_write_buf(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
614 if ((bta_pan_cb.flow_mask & BTA_PAN_RX_MASK) == BTA_PAN_RX_PUSH_BUF) {
615 bta_pan_pm_conn_busy(p_scb);
616
617 PAN_WriteBuf(p_scb->handle, ((tBTA_PAN_DATA_PARAMS*)p_data)->dst,
618 ((tBTA_PAN_DATA_PARAMS*)p_data)->src,
619 ((tBTA_PAN_DATA_PARAMS*)p_data)->protocol, (BT_HDR*)p_data,
620 ((tBTA_PAN_DATA_PARAMS*)p_data)->ext);
621 bta_pan_pm_conn_idle(p_scb);
622 }
623 }
624
625 /*******************************************************************************
626 *
627 * Function bta_pan_free_buf
628 *
629 * Description Frees the data buffer during closing state
630 *
631 *
632 * Returns void
633 *
634 ******************************************************************************/
bta_pan_free_buf(UNUSED_ATTR tBTA_PAN_SCB * p_scb,tBTA_PAN_DATA * p_data)635 void bta_pan_free_buf(UNUSED_ATTR tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
636 osi_free(p_data);
637 }
638
639 #endif /* PAN_INCLUDED */
640