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