1 /****************************************************************************** 2 * 3 * Copyright (C) 2010-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 private interface file for the NFA P2P. 22 * 23 ******************************************************************************/ 24 #ifndef NFA_P2P_INT_H 25 #define NFA_P2P_INT_H 26 27 #if (defined (NFA_P2P_INCLUDED) && (NFA_P2P_INCLUDED==TRUE)) 28 #include "nfa_p2p_api.h" 29 #include "nfa_dm_int.h" 30 31 /***************************************************************************** 32 ** Constants and data types 33 *****************************************************************************/ 34 #define NFA_P2P_DEBUG BT_TRACE_VERBOSE 35 36 /* NFA P2P LLCP link state */ 37 enum 38 { 39 NFA_P2P_LLCP_STATE_IDLE, 40 NFA_P2P_LLCP_STATE_LISTENING, 41 NFA_P2P_LLCP_STATE_ACTIVATED, 42 43 NFA_P2P_LLCP_STATE_MAX 44 }; 45 46 typedef UINT8 tNFA_P2P_LLCP_STATE; 47 48 /* NFA P2P events */ 49 enum 50 { 51 NFA_P2P_API_REG_SERVER_EVT = NFA_SYS_EVT_START (NFA_ID_P2P), 52 NFA_P2P_API_REG_CLIENT_EVT, 53 NFA_P2P_API_DEREG_EVT, 54 NFA_P2P_API_ACCEPT_CONN_EVT, 55 NFA_P2P_API_REJECT_CONN_EVT, 56 NFA_P2P_API_DISCONNECT_EVT, 57 NFA_P2P_API_CONNECT_EVT, 58 NFA_P2P_API_SEND_UI_EVT, 59 NFA_P2P_API_SEND_DATA_EVT, 60 NFA_P2P_API_SET_LOCAL_BUSY_EVT, 61 NFA_P2P_API_GET_LINK_INFO_EVT, 62 NFA_P2P_API_GET_REMOTE_SAP_EVT, 63 NFA_P2P_API_SET_LLCP_CFG_EVT, 64 65 NFA_P2P_LAST_EVT 66 }; 67 68 /* data type for NFA_P2P_API_REG_SERVER_EVT */ 69 typedef struct 70 { 71 BT_HDR hdr; 72 UINT8 server_sap; 73 tNFA_P2P_LINK_TYPE link_type; 74 char service_name[LLCP_MAX_SN_LEN + 1]; 75 tNFA_P2P_CBACK *p_cback; 76 } tNFA_P2P_API_REG_SERVER; 77 78 /* data type for NFA_P2P_API_REG_CLIENT_EVT */ 79 typedef struct 80 { 81 BT_HDR hdr; 82 tNFA_P2P_LINK_TYPE link_type; 83 tNFA_P2P_CBACK *p_cback; 84 } tNFA_P2P_API_REG_CLIENT; 85 86 /* data type for NFA_P2P_API_DEREG_EVT */ 87 typedef struct 88 { 89 BT_HDR hdr; 90 tNFA_HANDLE handle; 91 } tNFA_P2P_API_DEREG; 92 93 /* data type for NFA_P2P_API_ACCEPT_CONN_EVT */ 94 typedef struct 95 { 96 BT_HDR hdr; 97 tNFA_HANDLE conn_handle; 98 UINT16 miu; 99 UINT8 rw; 100 } tNFA_P2P_API_ACCEPT_CONN; 101 102 /* data type for NFA_P2P_API_REJECT_CONN_EVT */ 103 typedef struct 104 { 105 BT_HDR hdr; 106 tNFA_HANDLE conn_handle; 107 } tNFA_P2P_API_REJECT_CONN; 108 109 /* data type for NFA_P2P_API_DISCONNECT_EVT */ 110 typedef struct 111 { 112 BT_HDR hdr; 113 tNFA_HANDLE conn_handle; 114 BOOLEAN flush; 115 } tNFA_P2P_API_DISCONNECT; 116 117 /* data type for NFA_P2P_API_CONNECT_EVT */ 118 typedef struct 119 { 120 BT_HDR hdr; 121 tNFA_HANDLE client_handle; 122 char service_name[LLCP_MAX_SN_LEN + 1]; 123 UINT8 dsap; 124 UINT16 miu; 125 UINT8 rw; 126 } tNFA_P2P_API_CONNECT; 127 128 /* data type for NFA_P2P_API_SEND_UI_EVT */ 129 typedef struct 130 { 131 BT_HDR hdr; 132 tNFA_HANDLE handle; 133 UINT8 dsap; 134 BT_HDR *p_msg; 135 } tNFA_P2P_API_SEND_UI; 136 137 /* data type for NFA_P2P_API_SEND_DATA_EVT */ 138 typedef struct 139 { 140 BT_HDR hdr; 141 tNFA_HANDLE conn_handle; 142 BT_HDR *p_msg; 143 } tNFA_P2P_API_SEND_DATA; 144 145 /* data type for NFA_P2P_API_SET_LOCAL_BUSY_EVT */ 146 typedef struct 147 { 148 BT_HDR hdr; 149 tNFA_HANDLE conn_handle; 150 BOOLEAN is_busy; 151 } tNFA_P2P_API_SET_LOCAL_BUSY; 152 153 /* data type for NFA_P2P_API_GET_LINK_INFO_EVT */ 154 typedef struct 155 { 156 BT_HDR hdr; 157 tNFA_HANDLE handle; 158 } tNFA_P2P_API_GET_LINK_INFO; 159 160 /* data type for NFA_P2P_API_GET_REMOTE_SAP_EVT */ 161 typedef struct 162 { 163 BT_HDR hdr; 164 tNFA_HANDLE handle; 165 char service_name[LLCP_MAX_SN_LEN + 1]; 166 } tNFA_P2P_API_GET_REMOTE_SAP; 167 168 /* data type for NFA_P2P_API_SET_LLCP_CFG_EVT */ 169 typedef struct 170 { 171 BT_HDR hdr; 172 UINT16 link_miu; 173 UINT8 opt; 174 UINT8 wt; 175 UINT16 link_timeout; 176 UINT16 inact_timeout_init; 177 UINT16 inact_timeout_target; 178 UINT16 symm_delay; 179 UINT16 data_link_timeout; 180 UINT16 delay_first_pdu_timeout; 181 } tNFA_P2P_API_SET_LLCP_CFG; 182 183 /* union of all event data types */ 184 typedef union 185 { 186 BT_HDR hdr; 187 tNFA_P2P_API_REG_SERVER api_reg_server; 188 tNFA_P2P_API_REG_CLIENT api_reg_client; 189 tNFA_P2P_API_DEREG api_dereg; 190 tNFA_P2P_API_ACCEPT_CONN api_accept; 191 tNFA_P2P_API_REJECT_CONN api_reject; 192 tNFA_P2P_API_DISCONNECT api_disconnect; 193 tNFA_P2P_API_CONNECT api_connect; 194 tNFA_P2P_API_SEND_UI api_send_ui; 195 tNFA_P2P_API_SEND_DATA api_send_data; 196 tNFA_P2P_API_SET_LOCAL_BUSY api_local_busy; 197 tNFA_P2P_API_GET_LINK_INFO api_link_info; 198 tNFA_P2P_API_GET_REMOTE_SAP api_remote_sap; 199 tNFA_P2P_API_SET_LLCP_CFG api_set_llcp_cfg; 200 } tNFA_P2P_MSG; 201 202 /***************************************************************************** 203 ** control block 204 *****************************************************************************/ 205 #define NFA_P2P_HANDLE_FLAG_CONN 0x80 /* Bit flag for connection handle */ 206 207 /* NFA P2P Connection block */ 208 #define NFA_P2P_CONN_FLAG_IN_USE 0x01 /* Connection control block is used */ 209 #define NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO 0x02 /* Remote set RW to 0 (flow off) */ 210 #define NFA_P2P_CONN_FLAG_CONGESTED 0x04 /* data link connection is congested */ 211 212 typedef struct 213 { 214 UINT8 flags; /* internal flags for data link connection */ 215 UINT8 local_sap; /* local SAP of data link connection */ 216 UINT8 remote_sap; /* remote SAP of data link connection */ 217 UINT16 remote_miu; /* MIU of remote end point */ 218 UINT8 num_pending_i_pdu; /* number of tx I PDU not processed by NFA */ 219 } tNFA_P2P_CONN_CB; 220 221 /* NFA P2P SAP control block */ 222 #define NFA_P2P_SAP_FLAG_SERVER 0x01 /* registered server */ 223 #define NFA_P2P_SAP_FLAG_CLIENT 0x02 /* registered client */ 224 #define NFA_P2P_SAP_FLAG_LLINK_CONGESTED 0x04 /* logical link connection is congested */ 225 226 typedef struct 227 { 228 UINT8 flags; /* internal flags for local SAP */ 229 tNFA_P2P_CBACK *p_cback; /* callback function for local SAP */ 230 UINT8 num_pending_ui_pdu; /* number of tx UI PDU not processed by NFA */ 231 } tNFA_P2P_SAP_CB; 232 233 /* NFA P2P SDP control block */ 234 typedef struct 235 { 236 UINT8 tid; /* transaction ID */ 237 UINT8 local_sap; 238 } tNFA_P2P_SDP_CB; 239 240 #define NFA_P2P_NUM_SAP 64 241 242 /* NFA P2P control block */ 243 typedef struct 244 { 245 tNFA_HANDLE dm_disc_handle; 246 247 tNFA_P2P_LLCP_STATE llcp_state; 248 BOOLEAN is_initiator; 249 UINT16 local_link_miu; 250 UINT16 remote_link_miu; 251 252 tNFA_TECHNOLOGY_MASK listen_tech_mask; /* for P2P listening */ 253 BOOLEAN is_p2p_listening; 254 BOOLEAN is_cho_listening; 255 BOOLEAN is_snep_listening; 256 257 tNFA_P2P_SAP_CB sap_cb[NFA_P2P_NUM_SAP]; 258 tNFA_P2P_CONN_CB conn_cb[LLCP_MAX_DATA_LINK]; 259 tNFA_P2P_SDP_CB sdp_cb[LLCP_MAX_SDP_TRANSAC]; 260 261 UINT8 total_pending_ui_pdu; /* total number of tx UI PDU not processed by NFA */ 262 UINT8 total_pending_i_pdu; /* total number of tx I PDU not processed by NFA */ 263 264 UINT8 trace_level; 265 } tNFA_P2P_CB; 266 267 /***************************************************************************** 268 ** External variables 269 *****************************************************************************/ 270 271 /* NFA P2P control block */ 272 #if NFA_DYNAMIC_MEMORY == FALSE 273 extern tNFA_P2P_CB nfa_p2p_cb; 274 #else 275 extern tNFA_P2P_CB *nfa_p2p_cb_ptr; 276 #define nfa_p2p_cb (*nfa_p2p_cb_ptr) 277 #endif 278 279 /***************************************************************************** 280 ** External functions 281 *****************************************************************************/ 282 /* 283 ** nfa_p2p_main.c 284 */ 285 void nfa_p2p_init (void); 286 void nfa_p2p_update_listen_tech (tNFA_TECHNOLOGY_MASK tech_mask); 287 void nfa_p2p_enable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks); 288 void nfa_p2p_disable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks); 289 void nfa_p2p_activate_llcp (tNFC_DISCOVER *p_data); 290 void nfa_p2p_deactivate_llcp (void); 291 void nfa_p2p_set_config (tNFA_DM_DISC_TECH_PROTO_MASK disc_mask); 292 293 /* 294 ** nfa_p2p_act.c 295 */ 296 void nfa_p2p_proc_llcp_data_ind (tLLCP_SAP_CBACK_DATA *p_data); 297 void nfa_p2p_proc_llcp_connect_ind (tLLCP_SAP_CBACK_DATA *p_data); 298 void nfa_p2p_proc_llcp_connect_resp (tLLCP_SAP_CBACK_DATA *p_data); 299 void nfa_p2p_proc_llcp_disconnect_ind (tLLCP_SAP_CBACK_DATA *p_data); 300 void nfa_p2p_proc_llcp_disconnect_resp (tLLCP_SAP_CBACK_DATA *p_data); 301 void nfa_p2p_proc_llcp_congestion (tLLCP_SAP_CBACK_DATA *p_data); 302 void nfa_p2p_proc_llcp_link_status (tLLCP_SAP_CBACK_DATA *p_data); 303 304 BOOLEAN nfa_p2p_start_sdp (char *p_service_name, UINT8 local_sap); 305 306 BOOLEAN nfa_p2p_reg_server (tNFA_P2P_MSG *p_msg); 307 BOOLEAN nfa_p2p_reg_client (tNFA_P2P_MSG *p_msg); 308 BOOLEAN nfa_p2p_dereg (tNFA_P2P_MSG *p_msg); 309 BOOLEAN nfa_p2p_accept_connection (tNFA_P2P_MSG *p_msg); 310 BOOLEAN nfa_p2p_reject_connection (tNFA_P2P_MSG *p_msg); 311 BOOLEAN nfa_p2p_disconnect (tNFA_P2P_MSG *p_msg); 312 BOOLEAN nfa_p2p_create_data_link_connection (tNFA_P2P_MSG *p_msg); 313 BOOLEAN nfa_p2p_send_ui (tNFA_P2P_MSG *p_msg); 314 BOOLEAN nfa_p2p_send_data (tNFA_P2P_MSG *p_msg); 315 BOOLEAN nfa_p2p_set_local_busy (tNFA_P2P_MSG *p_msg); 316 BOOLEAN nfa_p2p_get_link_info (tNFA_P2P_MSG *p_msg); 317 BOOLEAN nfa_p2p_get_remote_sap (tNFA_P2P_MSG *p_msg); 318 BOOLEAN nfa_p2p_set_llcp_cfg (tNFA_P2P_MSG *p_msg); 319 320 #if (BT_TRACE_VERBOSE == TRUE) 321 char *nfa_p2p_evt_code (UINT16 evt_code); 322 #endif 323 324 #else 325 326 #define nfa_p2p_init () 327 #define nfa_p2p_activate_llcp (a) {}; 328 #define nfa_p2p_deactivate_llcp () 329 #define nfa_p2p_set_config () 330 331 #endif /* (defined (NFA_P2P_INCLUDED) && (NFA_P2P_INCLUDED==TRUE)) */ 332 #endif /* NFA_P2P_INT_H */ 333