• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2001-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 internally used PAN definitions
22  *
23  ******************************************************************************/
24 
25 #ifndef PAN_INT_H
26 #define PAN_INT_H
27 
28 #include <cstdint>
29 
30 #include "stack/include/bt_hdr.h"
31 #include "stack/include/pan_api.h"
32 #include "types/bluetooth/uuid.h"
33 #include "types/raw_address.h"
34 
35 /*
36  * This role is used to shutdown the profile. Used internally
37  * Applications should call PAN_Deregister to shutdown the profile
38  */
39 #define PAN_ROLE_INACTIVE 0
40 
41 #define PAN_PROFILE_VERSION 0x0100 /* Version 1.00 */
42 
43 typedef enum : uint8_t {
44   PAN_STATE_IDLE = 0,
45   PAN_STATE_CONN_START = 1,
46   PAN_STATE_CONNECTED = 2,
47 } tPAN_STATE;
48 
49 /* Define the PAN Connection Control Block
50  */
51 typedef struct {
52   tPAN_STATE con_state;
53 
54 #define PAN_FLAGS_CONN_COMPLETED 0x01
55   uint8_t con_flags;
56 
57   uint16_t handle;
58   RawAddress rem_bda;
59 
60   uint16_t bad_pkts_rcvd;
61   uint16_t src_uuid;
62   uint16_t dst_uuid;
63   uint16_t prv_src_uuid;
64   uint16_t prv_dst_uuid;
65   uint16_t ip_addr_known;
66   uint32_t ip_addr;
67 
68   struct {
69     size_t octets{0};
70     size_t packets{0};
71     size_t errors{0};
72     size_t drops{0};
73   } write, read;
74 
75 } tPAN_CONN;
76 
77 /*  The main PAN control block
78  */
79 typedef struct {
80   tPAN_ROLE role;
81   tPAN_ROLE active_role;
82   tPAN_ROLE prv_active_role;
83   tPAN_CONN pcb[MAX_PAN_CONNS];
84 
85   tPAN_CONN_STATE_CB* pan_conn_state_cb; /* Connection state callback */
86   tPAN_BRIDGE_REQ_CB* pan_bridge_req_cb;
87   tPAN_DATA_IND_CB* pan_data_ind_cb;
88   tPAN_DATA_BUF_IND_CB* pan_data_buf_ind_cb;
89   tPAN_FILTER_IND_CB*
90       pan_pfilt_ind_cb; /* protocol filter indication callback */
91   tPAN_MFILTER_IND_CB*
92       pan_mfilt_ind_cb; /* multicast filter indication callback */
93   tPAN_TX_DATA_FLOW_CB* pan_tx_data_flow_cb;
94 
95   char* user_service_name;
96   char* gn_service_name;
97   char* nap_service_name;
98   uint32_t pan_user_sdp_handle;
99   uint32_t pan_gn_sdp_handle;
100   uint32_t pan_nap_sdp_handle;
101   uint8_t num_conns;
102   uint8_t trace_level;
103 } tPAN_CB;
104 
105 /* Global PAN data
106  */
107 extern tPAN_CB pan_cb;
108 
109 /******************************************************************************/
110 extern void pan_register_with_bnep(void);
111 extern void pan_conn_ind_cb(uint16_t handle, const RawAddress& p_bda,
112                             const bluetooth::Uuid& remote_uuid,
113                             const bluetooth::Uuid& local_uuid,
114                             bool is_role_change);
115 extern void pan_connect_state_cb(uint16_t handle, const RawAddress& rem_bda,
116                                  tBNEP_RESULT result, bool is_role_change);
117 extern void pan_data_buf_ind_cb(uint16_t handle, const RawAddress& src,
118                                 const RawAddress& dst, uint16_t protocol,
119                                 BT_HDR* p_buf, bool ext);
120 extern void pan_tx_data_flow_cb(uint16_t handle, tBNEP_RESULT event);
121 void pan_proto_filt_ind_cb(uint16_t handle, bool indication,
122                            tBNEP_RESULT result, uint16_t num_filters,
123                            uint8_t* p_filters);
124 void pan_mcast_filt_ind_cb(uint16_t handle, bool indication,
125                            tBNEP_RESULT result, uint16_t num_filters,
126                            uint8_t* p_filters);
127 extern uint32_t pan_register_with_sdp(uint16_t uuid, const char* p_name,
128                                       const char* p_desc);
129 extern tPAN_CONN* pan_allocate_pcb(const RawAddress& p_bda, uint16_t handle);
130 extern tPAN_CONN* pan_get_pcb_by_handle(uint16_t handle);
131 extern tPAN_CONN* pan_get_pcb_by_addr(const RawAddress& p_bda);
132 extern void pan_close_all_connections(void);
133 extern void pan_release_pcb(tPAN_CONN* p_pcb);
134 extern void pan_dump_status(void);
135 
136 /******************************************************************************/
137 
138 #endif
139