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 is the implementation file for data gateway call-in functions.
22  *
23  ******************************************************************************/
24 
25 #include "bta/include/bta_pan_ci.h"
26 
27 #include <cstddef>
28 #include <cstdint>
29 
30 #include "bta/pan/bta_pan_int.h"
31 #include "osi/include/fixed_queue.h"
32 #include "stack/include/bt_hdr.h"
33 #include "types/raw_address.h"
34 
35 /*******************************************************************************
36  *
37  * Function         bta_pan_ci_readbuf
38  *
39  * Description
40  *
41  *
42  * Returns          void
43  *
44  ******************************************************************************/
bta_pan_ci_readbuf(uint16_t handle,RawAddress & src,RawAddress & dst,uint16_t * p_protocol,bool * p_ext,bool * p_forward)45 BT_HDR* bta_pan_ci_readbuf(uint16_t handle, RawAddress& src, RawAddress& dst, uint16_t* p_protocol,
46                            bool* p_ext, bool* p_forward) {
47   tBTA_PAN_SCB* p_scb = bta_pan_scb_by_handle(handle);
48   BT_HDR* p_buf;
49 
50   if (p_scb == NULL) {
51     return NULL;
52   }
53 
54   p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_scb->data_queue);
55   if (p_buf != NULL) {
56     src = ((tBTA_PAN_DATA_PARAMS*)p_buf)->src;
57     dst = ((tBTA_PAN_DATA_PARAMS*)p_buf)->dst;
58     *p_protocol = ((tBTA_PAN_DATA_PARAMS*)p_buf)->protocol;
59     *p_ext = ((tBTA_PAN_DATA_PARAMS*)p_buf)->ext;
60     *p_forward = ((tBTA_PAN_DATA_PARAMS*)p_buf)->forward;
61   }
62 
63   return p_buf;
64 }
65