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