1 /******************************************************************************
2  *
3  *  Copyright (C) 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 /* Protocols supported by the host internal stack, are registered with SDP */
37 #define PAN_PROTOCOL_IP        0x0800
38 #define PAN_PROTOCOL_ARP       0x0806
39 
40 #define PAN_PROFILE_VERSION    0x0100   /* Version 1.00 */
41 
42 /* Define the PAN Connection Control Block
43 */
44 typedef struct
45 {
46 #define PAN_STATE_IDLE              0
47 #define PAN_STATE_CONN_START        1
48 #define PAN_STATE_CONNECTED         2
49     UINT8             con_state;
50 
51 #define PAN_FLAGS_CONN_COMPLETED    0x01
52     UINT8             con_flags;
53 
54     UINT16            handle;
55     BD_ADDR           rem_bda;
56 
57     UINT16            bad_pkts_rcvd;
58     UINT16            src_uuid;
59     UINT16            dst_uuid;
60     UINT16            prv_src_uuid;
61     UINT16            prv_dst_uuid;
62     UINT16            ip_addr_known;
63     UINT32            ip_addr;
64 
65 } tPAN_CONN;
66 
67 
68 /*  The main PAN control block
69 */
70 typedef struct
71 {
72     UINT8                       role;
73     UINT8                       active_role;
74     UINT8                       prv_active_role;
75     tPAN_CONN                   pcb[MAX_PAN_CONNS];
76 
77     tPAN_CONN_STATE_CB          *pan_conn_state_cb;     /* Connection state callback */
78     tPAN_BRIDGE_REQ_CB          *pan_bridge_req_cb;
79     tPAN_DATA_IND_CB            *pan_data_ind_cb;
80     tPAN_DATA_BUF_IND_CB        *pan_data_buf_ind_cb;
81     tPAN_FILTER_IND_CB          *pan_pfilt_ind_cb;      /* protocol filter indication callback */
82     tPAN_MFILTER_IND_CB         *pan_mfilt_ind_cb;      /* multicast filter indication callback */
83     tPAN_TX_DATA_FLOW_CB        *pan_tx_data_flow_cb;
84 
85     char                        *user_service_name;
86     char                        *gn_service_name;
87     char                        *nap_service_name;
88     UINT32                      pan_user_sdp_handle;
89     UINT32                      pan_gn_sdp_handle;
90     UINT32                      pan_nap_sdp_handle;
91     UINT8                       num_conns;
92     UINT8                       trace_level;
93 } tPAN_CB;
94 
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100 /* Global PAN data
101 */
102 #if PAN_DYNAMIC_MEMORY == FALSE
103 extern tPAN_CB  pan_cb;
104 #else
105 extern tPAN_CB  *pan_cb_ptr;
106 #define pan_cb (*pan_cb_ptr)
107 #endif
108 
109 /*******************************************************************************/
110 extern void pan_register_with_bnep (void);
111 extern void pan_conn_ind_cb (UINT16 handle,
112                              BD_ADDR p_bda,
113                              tBT_UUID *remote_uuid,
114                              tBT_UUID *local_uuid,
115                              BOOLEAN is_role_change);
116 extern void pan_connect_state_cb (UINT16 handle, BD_ADDR rem_bda, tBNEP_RESULT result, BOOLEAN is_role_change);
117 extern void pan_data_ind_cb (UINT16 handle,
118                              UINT8 *src,
119                              UINT8 *dst,
120                              UINT16 protocol,
121                              UINT8 *p_data,
122                              UINT16 len,
123                              BOOLEAN fw_ext_present);
124 extern void pan_data_buf_ind_cb (UINT16 handle,
125                                  UINT8 *src,
126                                  UINT8 *dst,
127                                  UINT16 protocol,
128                                  BT_HDR *p_buf,
129                                  BOOLEAN ext);
130 extern void pan_tx_data_flow_cb (UINT16 handle,
131                             tBNEP_RESULT  event);
132 void pan_proto_filt_ind_cb (UINT16 handle,
133                             BOOLEAN indication,
134                             tBNEP_RESULT result,
135                             UINT16 num_filters,
136                             UINT8 *p_filters);
137 void pan_mcast_filt_ind_cb (UINT16 handle,
138                             BOOLEAN indication,
139                             tBNEP_RESULT result,
140                             UINT16 num_filters,
141                             UINT8 *p_filters);
142 extern UINT32 pan_register_with_sdp (UINT16 uuid, UINT8 sec_mask, char *p_name, char *p_desc);
143 extern tPAN_CONN *pan_allocate_pcb (BD_ADDR p_bda, UINT16 handle);
144 extern tPAN_CONN *pan_get_pcb_by_handle (UINT16 handle);
145 extern tPAN_CONN *pan_get_pcb_by_addr (BD_ADDR p_bda);
146 extern void pan_close_all_connections (void);
147 extern void pan_release_pcb (tPAN_CONN *p_pcb);
148 extern void pan_dump_status (void);
149 
150 /********************************************************************************/
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif
157