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 BNEP definitions 22 * 23 ******************************************************************************/ 24 25 #ifndef BNEP_INT_H 26 #define BNEP_INT_H 27 28 #include "bt_target.h" 29 #include "gki.h" 30 #include "bnep_api.h" 31 #include "btm_int.h" 32 #include "btu.h" 33 34 35 /* BNEP frame types 36 */ 37 #define BNEP_FRAME_GENERAL_ETHERNET 0x00 38 #define BNEP_FRAME_CONTROL 0x01 39 #define BNEP_FRAME_COMPRESSED_ETHERNET 0x02 40 #define BNEP_FRAME_COMPRESSED_ETHERNET_SRC_ONLY 0x03 41 #define BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY 0x04 42 43 44 /* BNEP filter control message types 45 */ 46 #define BNEP_CONTROL_COMMAND_NOT_UNDERSTOOD 0x00 47 #define BNEP_SETUP_CONNECTION_REQUEST_MSG 0x01 48 #define BNEP_SETUP_CONNECTION_RESPONSE_MSG 0x02 49 #define BNEP_FILTER_NET_TYPE_SET_MSG 0x03 50 #define BNEP_FILTER_NET_TYPE_RESPONSE_MSG 0x04 51 #define BNEP_FILTER_MULTI_ADDR_SET_MSG 0x05 52 #define BNEP_FILTER_MULTI_ADDR_RESPONSE_MSG 0x06 53 54 55 /* BNEP header extension types 56 */ 57 #define BNEP_EXTENSION_FILTER_CONTROL 0x00 58 59 60 /* BNEP Setup Connection response codes 61 */ 62 #define BNEP_SETUP_CONN_OK 0x0000 63 #define BNEP_SETUP_INVALID_DEST_UUID 0x0001 64 #define BNEP_SETUP_INVALID_SRC_UUID 0x0002 65 #define BNEP_SETUP_INVALID_UUID_SIZE 0x0003 66 #define BNEP_SETUP_CONN_NOT_ALLOWED 0x0004 67 68 69 /* BNEP filter control response codes 70 */ 71 #define BNEP_FILTER_CRL_OK 0x0000 72 #define BNEP_FILTER_CRL_UNSUPPORTED 0x0001 73 #define BNEP_FILTER_CRL_BAD_RANGE 0x0002 74 #define BNEP_FILTER_CRL_MAX_REACHED 0x0003 75 #define BNEP_FILTER_CRL_SECURITY_ERR 0x0004 76 77 78 /* 802.1p protocol packet will have actual protocol field in side the payload */ 79 #define BNEP_802_1_P_PROTOCOL 0x8100 80 81 /* Timeout definitions. 82 */ 83 #define BNEP_CONN_TIMEOUT 20 /* Connection related timeout */ 84 #define BNEP_HOST_TIMEOUT 200 /* host responce timeout */ 85 #define BNEP_FILTER_SET_TIMEOUT 10 86 87 /* Define the Out-Flow default values. */ 88 #define BNEP_OFLOW_QOS_FLAG 0 89 #define BNEP_OFLOW_SERV_TYPE 0 90 #define BNEP_OFLOW_TOKEN_RATE 0 91 #define BNEP_OFLOW_TOKEN_BUCKET_SIZE 0 92 #define BNEP_OFLOW_PEAK_BANDWIDTH 0 93 #define BNEP_OFLOW_LATENCY 0 94 #define BNEP_OFLOW_DELAY_VARIATION 0 95 96 /* Define the In-Flow default values. */ 97 #define BNEP_IFLOW_QOS_FLAG 0 98 #define BNEP_IFLOW_SERV_TYPE 0 99 #define BNEP_IFLOW_TOKEN_RATE 0 100 #define BNEP_IFLOW_TOKEN_BUCKET_SIZE 0 101 #define BNEP_IFLOW_PEAK_BANDWIDTH 0 102 #define BNEP_IFLOW_LATENCY 0 103 #define BNEP_IFLOW_DELAY_VARIATION 0 104 105 #define BNEP_FLUSH_TO 0xFFFF 106 107 #define BNEP_MAX_RETRANSMITS 3 108 109 /* Define the BNEP Connection Control Block 110 */ 111 typedef struct 112 { 113 #define BNEP_STATE_IDLE 0 114 #define BNEP_STATE_CONN_START 1 115 #define BNEP_STATE_CFG_SETUP 2 116 #define BNEP_STATE_CONN_SETUP 3 117 #define BNEP_STATE_SEC_CHECKING 4 118 #define BNEP_STATE_SETUP_RCVD 5 119 #define BNEP_STATE_CONNECTED 6 120 UINT8 con_state; 121 122 #define BNEP_FLAGS_IS_ORIG 0x01 123 #define BNEP_FLAGS_HIS_CFG_DONE 0x02 124 #define BNEP_FLAGS_MY_CFG_DONE 0x04 125 #define BNEP_FLAGS_L2CAP_CONGESTED 0x08 126 #define BNEP_FLAGS_FILTER_RESP_PEND 0x10 127 #define BNEP_FLAGS_MULTI_RESP_PEND 0x20 128 #define BNEP_FLAGS_SETUP_RCVD 0x40 129 #define BNEP_FLAGS_CONN_COMPLETED 0x80 130 UINT8 con_flags; 131 BT_HDR *p_pending_data; 132 133 UINT16 l2cap_cid; 134 BD_ADDR rem_bda; 135 UINT16 rem_mtu_size; 136 TIMER_LIST_ENT conn_tle; 137 BUFFER_Q xmit_q; 138 139 UINT16 sent_num_filters; 140 UINT16 sent_prot_filter_start[BNEP_MAX_PROT_FILTERS]; 141 UINT16 sent_prot_filter_end[BNEP_MAX_PROT_FILTERS]; 142 143 UINT16 sent_mcast_filters; 144 BD_ADDR sent_mcast_filter_start[BNEP_MAX_MULTI_FILTERS]; 145 BD_ADDR sent_mcast_filter_end[BNEP_MAX_MULTI_FILTERS]; 146 147 UINT16 rcvd_num_filters; 148 UINT16 rcvd_prot_filter_start[BNEP_MAX_PROT_FILTERS]; 149 UINT16 rcvd_prot_filter_end[BNEP_MAX_PROT_FILTERS]; 150 151 UINT16 rcvd_mcast_filters; 152 BD_ADDR rcvd_mcast_filter_start[BNEP_MAX_MULTI_FILTERS]; 153 BD_ADDR rcvd_mcast_filter_end[BNEP_MAX_MULTI_FILTERS]; 154 155 UINT16 bad_pkts_rcvd; 156 UINT8 re_transmits; 157 UINT16 handle; 158 tBT_UUID prv_src_uuid; 159 tBT_UUID prv_dst_uuid; 160 tBT_UUID src_uuid; 161 tBT_UUID dst_uuid; 162 163 } tBNEP_CONN; 164 165 166 /* The main BNEP control block 167 */ 168 typedef struct 169 { 170 tL2CAP_CFG_INFO l2cap_my_cfg; /* My L2CAP config */ 171 tBNEP_CONN bcb[BNEP_MAX_CONNECTIONS]; 172 173 tBNEP_CONNECT_IND_CB *p_conn_ind_cb; 174 tBNEP_CONN_STATE_CB *p_conn_state_cb; 175 tBNEP_DATA_IND_CB *p_data_ind_cb; 176 tBNEP_DATA_BUF_CB *p_data_buf_cb; 177 tBNEP_FILTER_IND_CB *p_filter_ind_cb; 178 tBNEP_MFILTER_IND_CB *p_mfilter_ind_cb; 179 tBNEP_TX_DATA_FLOW_CB *p_tx_data_flow_cb; 180 181 tL2CAP_APPL_INFO reg_info; 182 183 TIMER_LIST_ENT bnep_tle; 184 BOOLEAN profile_registered; /* TRUE when we got our BD addr */ 185 UINT8 trace_level; 186 BOOLEAN got_my_bd_addr; /* TRUE when we got our BD addr */ 187 BD_ADDR my_bda; /* BD Address of this device */ 188 189 } tBNEP_CB; 190 191 #ifdef __cplusplus 192 extern "C" { 193 #endif 194 195 /* Global BNEP data 196 */ 197 #if BNEP_DYNAMIC_MEMORY == FALSE 198 BNEP_API extern tBNEP_CB bnep_cb; 199 #else 200 BNEP_API extern tBNEP_CB *bnep_cb_ptr; 201 #define bnep_cb (*bnep_cb_ptr) 202 #endif 203 204 /* Functions provided by bnep_main.c 205 */ 206 extern tBNEP_RESULT bnep_register_with_l2cap (void); 207 extern void bnep_disconnect (tBNEP_CONN *p_bcb, UINT16 reason); 208 extern tBNEP_CONN *bnep_conn_originate (UINT8 *p_bd_addr); 209 extern void bnep_process_timeout (TIMER_LIST_ENT *p_tle); 210 extern void bnep_connected (tBNEP_CONN *p_bcb); 211 212 213 /* Functions provided by bnep_utils.c 214 */ 215 extern tBNEP_CONN *bnepu_find_bcb_by_cid (UINT16 cid); 216 extern tBNEP_CONN *bnepu_find_bcb_by_bd_addr (UINT8 *p_bda); 217 extern tBNEP_CONN *bnepu_allocate_bcb (BD_ADDR p_rem_bda); 218 extern void bnepu_release_bcb (tBNEP_CONN *p_bcb); 219 extern void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb); 220 extern void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb); 221 extern BOOLEAN bnepu_does_dest_support_prot (tBNEP_CONN *p_bcb, UINT16 protocol); 222 extern void bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol, 223 UINT8 *p_src_addr, UINT8 *p_dest_addr, BOOLEAN ext_bit); 224 extern void test_bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol, 225 UINT8 *p_src_addr, UINT8 *p_dest_addr, UINT8 type); 226 227 extern tBNEP_CONN *bnepu_get_route_to_dest (UINT8 *p_bda); 228 extern void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf); 229 extern void bnep_send_command_not_understood (tBNEP_CONN *p_bcb, UINT8 cmd_code); 230 extern void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len); 231 extern void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data); 232 extern void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data); 233 extern void bnep_send_conn_req (tBNEP_CONN *p_bcb); 234 extern void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code); 235 extern void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len); 236 extern void bnep_process_setup_conn_responce (tBNEP_CONN *p_bcb, UINT8 *p_setup); 237 extern UINT8 *bnep_process_control_packet (tBNEP_CONN *p_bcb, UINT8 *p, UINT16 *len, BOOLEAN is_ext); 238 extern void bnep_sec_check_complete (BD_ADDR bd_addr, void *p_ref_data, UINT8 result); 239 extern tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BD_ADDR p_dest_addr, UINT16 protocol, BOOLEAN fw_ext_present, UINT8 *p_data); 240 extern UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid); 241 extern void bnep_dump_status (void); 242 243 244 245 #ifdef __cplusplus 246 } 247 #endif 248 249 250 #endif 251 252