nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2010-2014 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 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This is the implementation file for the NFA P2P. |
| 22 | * |
| 23 | ******************************************************************************/ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 24 | #include <android-base/stringprintf.h> |
| 25 | #include <base/logging.h> |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 26 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 27 | #include "llcp_api.h" |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 28 | #include "nfa_dm_int.h" |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 29 | #include "nfa_p2p_api.h" |
| 30 | #include "nfa_p2p_int.h" |
| 31 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 32 | using android::base::StringPrintf; |
| 33 | |
| 34 | extern bool nfc_debug_enabled; |
| 35 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 36 | /***************************************************************************** |
| 37 | ** Global Variables |
| 38 | *****************************************************************************/ |
| 39 | |
| 40 | /***************************************************************************** |
| 41 | ** Static Functions |
| 42 | *****************************************************************************/ |
| 43 | |
| 44 | /***************************************************************************** |
| 45 | ** Constants |
| 46 | *****************************************************************************/ |
| 47 | |
| 48 | /******************************************************************************* |
| 49 | ** |
| 50 | ** Function nfa_p2p_allocate_conn_cb |
| 51 | ** |
| 52 | ** Description Allocate data link connection control block |
| 53 | ** |
| 54 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 55 | ** Returns uint8_t |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 56 | ** |
| 57 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 58 | static uint8_t nfa_p2p_allocate_conn_cb(uint8_t local_sap) { |
| 59 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 60 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 61 | for (xx = 0; xx < LLCP_MAX_DATA_LINK; xx++) { |
| 62 | if (nfa_p2p_cb.conn_cb[xx].flags == 0) { |
| 63 | nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_IN_USE; |
| 64 | nfa_p2p_cb.conn_cb[xx].local_sap = local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 65 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 66 | return (xx); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 67 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 68 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 69 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 70 | LOG(ERROR) << StringPrintf("No resource"); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 71 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 72 | return LLCP_MAX_DATA_LINK; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /******************************************************************************* |
| 76 | ** |
| 77 | ** Function nfa_p2p_deallocate_conn_cb |
| 78 | ** |
| 79 | ** Description Deallocate data link connection control block |
| 80 | ** |
| 81 | ** |
| 82 | ** Returns void |
| 83 | ** |
| 84 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 85 | static void nfa_p2p_deallocate_conn_cb(uint8_t xx) { |
| 86 | if (xx < LLCP_MAX_DATA_LINK) { |
| 87 | nfa_p2p_cb.conn_cb[xx].flags = 0; |
| 88 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 89 | LOG(ERROR) << StringPrintf("Invalid index (%d)", xx); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 90 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /******************************************************************************* |
| 94 | ** |
| 95 | ** Function nfa_p2p_find_conn_cb |
| 96 | ** |
| 97 | ** Description Find data link connection control block by local/remote SAP |
| 98 | ** |
| 99 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 100 | ** Returns uint8_t |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 101 | ** |
| 102 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 103 | static uint8_t nfa_p2p_find_conn_cb(uint8_t local_sap, uint8_t remote_sap) { |
| 104 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 105 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 106 | for (xx = 0; xx < LLCP_MAX_DATA_LINK; xx++) { |
| 107 | if ((nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_IN_USE) && |
| 108 | (nfa_p2p_cb.conn_cb[xx].local_sap == local_sap) && |
| 109 | (nfa_p2p_cb.conn_cb[xx].remote_sap == remote_sap)) { |
| 110 | return (xx); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 111 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 112 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 113 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 114 | return (LLCP_MAX_DATA_LINK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /******************************************************************************* |
| 118 | ** |
| 119 | ** Function nfa_p2p_llcp_cback |
| 120 | ** |
| 121 | ** Description Processing SAP callback events from LLCP |
| 122 | ** |
| 123 | ** |
| 124 | ** Returns None |
| 125 | ** |
| 126 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 127 | static void nfa_p2p_llcp_cback(tLLCP_SAP_CBACK_DATA* p_data) { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 128 | DLOG_IF(INFO, nfc_debug_enabled) |
| 129 | << StringPrintf("event:0x%02X, local_sap:0x%02X", p_data->hdr.event, |
| 130 | p_data->hdr.local_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 131 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 132 | switch (p_data->hdr.event) { |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 133 | case LLCP_SAP_EVT_DATA_IND: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 134 | nfa_p2p_proc_llcp_data_ind(p_data); |
| 135 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 136 | |
| 137 | case LLCP_SAP_EVT_CONNECT_IND: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 138 | nfa_p2p_proc_llcp_connect_ind(p_data); |
| 139 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 140 | |
| 141 | case LLCP_SAP_EVT_CONNECT_RESP: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 142 | nfa_p2p_proc_llcp_connect_resp(p_data); |
| 143 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 144 | |
| 145 | case LLCP_SAP_EVT_DISCONNECT_IND: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 146 | nfa_p2p_proc_llcp_disconnect_ind(p_data); |
| 147 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 148 | |
| 149 | case LLCP_SAP_EVT_DISCONNECT_RESP: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 150 | nfa_p2p_proc_llcp_disconnect_resp(p_data); |
| 151 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 152 | |
| 153 | case LLCP_SAP_EVT_CONGEST: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 154 | nfa_p2p_proc_llcp_congestion(p_data); |
| 155 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 156 | |
| 157 | case LLCP_SAP_EVT_LINK_STATUS: |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 158 | nfa_p2p_proc_llcp_link_status(p_data); |
| 159 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 160 | |
| 161 | default: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 162 | LOG(ERROR) << StringPrintf("Unknown event:0x%02X", p_data->hdr.event); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 163 | return; |
| 164 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /******************************************************************************* |
| 168 | ** |
| 169 | ** Function nfa_p2p_sdp_cback |
| 170 | ** |
| 171 | ** Description Process SDP callback event from LLCP |
| 172 | ** |
| 173 | ** |
| 174 | ** Returns None |
| 175 | ** |
| 176 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 177 | void nfa_p2p_sdp_cback(uint8_t tid, uint8_t remote_sap) { |
| 178 | uint8_t local_sap; |
| 179 | uint8_t xx; |
| 180 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 181 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 182 | DLOG_IF(INFO, nfc_debug_enabled) |
| 183 | << StringPrintf("tid:0x%02X, remote_sap:0x%02X", tid, remote_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 184 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 185 | /* search for callback function to process */ |
| 186 | for (xx = 0; xx < LLCP_MAX_SDP_TRANSAC; xx++) { |
| 187 | if ((nfa_p2p_cb.sdp_cb[xx].local_sap != LLCP_INVALID_SAP) && |
| 188 | (nfa_p2p_cb.sdp_cb[xx].tid == tid)) { |
| 189 | local_sap = nfa_p2p_cb.sdp_cb[xx].local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 190 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 191 | evt_data.sdp.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 192 | evt_data.sdp.remote_sap = remote_sap; |
| 193 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_SDP_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 194 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 195 | nfa_p2p_cb.sdp_cb[xx].local_sap = LLCP_INVALID_SAP; |
| 196 | break; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 197 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 198 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /******************************************************************************* |
| 202 | ** |
| 203 | ** Function nfa_p2p_start_sdp |
| 204 | ** |
| 205 | ** Description Initiate SDP |
| 206 | ** |
| 207 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 208 | ** Returns TRUE if success |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 209 | ** |
| 210 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 211 | bool nfa_p2p_start_sdp(char* p_service_name, uint8_t local_sap) { |
| 212 | int xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 213 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 214 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("SN:<%s>", p_service_name); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 215 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 216 | /* search for empty slot */ |
| 217 | for (xx = 0; xx < LLCP_MAX_SDP_TRANSAC; xx++) { |
| 218 | if (nfa_p2p_cb.sdp_cb[xx].local_sap == LLCP_INVALID_SAP) { |
| 219 | if (LLCP_DiscoverService(p_service_name, nfa_p2p_sdp_cback, |
| 220 | &(nfa_p2p_cb.sdp_cb[xx].tid)) == |
| 221 | LLCP_STATUS_SUCCESS) { |
| 222 | nfa_p2p_cb.sdp_cb[xx].local_sap = local_sap; |
| 223 | return true; |
| 224 | } else { |
| 225 | /* failure of SDP */ |
| 226 | return false; |
| 227 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 228 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 229 | } |
| 230 | return false; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /******************************************************************************* |
| 234 | ** |
| 235 | ** Function nfa_p2p_proc_llcp_data_ind |
| 236 | ** |
| 237 | ** Description Processing incoming data event from LLCP |
| 238 | ** |
| 239 | ** |
| 240 | ** Returns None |
| 241 | ** |
| 242 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 243 | void nfa_p2p_proc_llcp_data_ind(tLLCP_SAP_CBACK_DATA* p_data) { |
| 244 | uint8_t local_sap, xx; |
| 245 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 246 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 247 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 248 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 249 | local_sap = p_data->data_ind.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 250 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 251 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 252 | evt_data.data.handle = 0; |
| 253 | /* if connectionless */ |
| 254 | if (p_data->data_ind.link_type == NFA_P2P_LLINK_TYPE) { |
| 255 | evt_data.data.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 256 | } else { |
| 257 | xx = nfa_p2p_find_conn_cb(p_data->data_ind.local_sap, |
| 258 | p_data->data_ind.remote_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 259 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 260 | if (xx != LLCP_MAX_DATA_LINK) { |
| 261 | evt_data.data.handle = |
| 262 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 263 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 264 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 265 | |
| 266 | evt_data.data.remote_sap = p_data->data_ind.remote_sap; |
| 267 | evt_data.data.link_type = p_data->data_ind.link_type; |
| 268 | |
| 269 | /* notify upper layer that there are data at LLCP */ |
| 270 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DATA_EVT, &evt_data); |
| 271 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /******************************************************************************* |
| 275 | ** |
| 276 | ** Function nfa_p2p_proc_llcp_connect_ind |
| 277 | ** |
| 278 | ** Description Processing connection request from peer |
| 279 | ** |
| 280 | ** |
| 281 | ** Returns None |
| 282 | ** |
| 283 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 284 | void nfa_p2p_proc_llcp_connect_ind(tLLCP_SAP_CBACK_DATA* p_data) { |
| 285 | uint8_t server_sap, local_sap; |
| 286 | tNFA_P2P_EVT_DATA evt_data; |
| 287 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 288 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 289 | DLOG_IF(INFO, nfc_debug_enabled) |
| 290 | << StringPrintf("server_sap:0x%x", p_data->connect_ind.server_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 291 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 292 | server_sap = p_data->connect_ind.server_sap; |
| 293 | local_sap = p_data->connect_ind.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 294 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 295 | if (nfa_p2p_cb.sap_cb[server_sap].p_cback) { |
| 296 | xx = nfa_p2p_allocate_conn_cb(server_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 297 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 298 | if (xx != LLCP_MAX_DATA_LINK) { |
| 299 | nfa_p2p_cb.conn_cb[xx].remote_sap = p_data->connect_ind.remote_sap; |
| 300 | nfa_p2p_cb.conn_cb[xx].remote_miu = p_data->connect_ind.miu; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 301 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 302 | /* peer will not receive any data */ |
| 303 | if (p_data->connect_ind.rw == 0) |
| 304 | nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 305 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 306 | evt_data.conn_req.server_handle = (NFA_HANDLE_GROUP_P2P | server_sap); |
| 307 | evt_data.conn_req.conn_handle = |
| 308 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 309 | evt_data.conn_req.remote_sap = p_data->connect_ind.remote_sap; |
| 310 | evt_data.conn_req.remote_miu = p_data->connect_ind.miu; |
| 311 | evt_data.conn_req.remote_rw = p_data->connect_ind.rw; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 312 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 313 | nfa_p2p_cb.sap_cb[server_sap].p_cback(NFA_P2P_CONN_REQ_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 314 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 315 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 316 | LOG(ERROR) << StringPrintf("Not registered"); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 317 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /******************************************************************************* |
| 321 | ** |
| 322 | ** Function nfa_p2p_proc_llcp_connect_resp |
| 323 | ** |
| 324 | ** Description Processing connection response from peer |
| 325 | ** |
| 326 | ** |
| 327 | ** Returns None |
| 328 | ** |
| 329 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 330 | void nfa_p2p_proc_llcp_connect_resp(tLLCP_SAP_CBACK_DATA* p_data) { |
| 331 | uint8_t local_sap, xx; |
| 332 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 333 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 334 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 335 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 336 | local_sap = p_data->connect_resp.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 337 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 338 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 339 | xx = nfa_p2p_allocate_conn_cb(local_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 340 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 341 | if (xx != LLCP_MAX_DATA_LINK) { |
| 342 | nfa_p2p_cb.conn_cb[xx].remote_sap = p_data->connect_resp.remote_sap; |
| 343 | nfa_p2p_cb.conn_cb[xx].remote_miu = p_data->connect_resp.miu; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 344 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 345 | /* peer will not receive any data */ |
| 346 | if (p_data->connect_resp.rw == 0) |
| 347 | nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 348 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 349 | evt_data.connected.client_handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 350 | evt_data.connected.conn_handle = |
| 351 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 352 | evt_data.connected.remote_sap = p_data->connect_resp.remote_sap; |
| 353 | evt_data.connected.remote_miu = p_data->connect_resp.miu; |
| 354 | evt_data.connected.remote_rw = p_data->connect_resp.rw; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 355 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 356 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONNECTED_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 357 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 358 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /******************************************************************************* |
| 362 | ** |
| 363 | ** Function nfa_p2p_proc_llcp_disconnect_ind |
| 364 | ** |
| 365 | ** Description Processing disconnection request from peer |
| 366 | ** |
| 367 | ** |
| 368 | ** Returns None |
| 369 | ** |
| 370 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 371 | void nfa_p2p_proc_llcp_disconnect_ind(tLLCP_SAP_CBACK_DATA* p_data) { |
| 372 | uint8_t local_sap, xx; |
| 373 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 374 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 375 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 376 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 377 | local_sap = p_data->disconnect_ind.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 378 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 379 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 380 | xx = nfa_p2p_find_conn_cb(p_data->disconnect_ind.local_sap, |
| 381 | p_data->disconnect_ind.remote_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 382 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 383 | if (xx != LLCP_MAX_DATA_LINK) { |
| 384 | evt_data.disc.handle = |
| 385 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 386 | evt_data.disc.reason = NFA_P2P_DISC_REASON_REMOTE_INITIATE; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 387 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 388 | nfa_p2p_deallocate_conn_cb(xx); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 389 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 390 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
| 391 | } else { |
| 392 | /* |
| 393 | ** LLCP link has been deactivated before receiving CC or DM. |
| 394 | ** Return NFA_P2P_DISC_EVT to indicate failure of creating |
| 395 | ** connection |
| 396 | */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 397 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 398 | evt_data.disc.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 399 | evt_data.disc.reason = NFA_P2P_DISC_REASON_LLCP_DEACTIVATED; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 400 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 401 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 402 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 403 | LOG(ERROR) << StringPrintf("Link deactivated"); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 404 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 405 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | /******************************************************************************* |
| 409 | ** |
| 410 | ** Function nfa_p2p_proc_llcp_disconnect_resp |
| 411 | ** |
| 412 | ** Description Processing rejected connection from peer |
| 413 | ** |
| 414 | ** |
| 415 | ** Returns None |
| 416 | ** |
| 417 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 418 | void nfa_p2p_proc_llcp_disconnect_resp(tLLCP_SAP_CBACK_DATA* p_data) { |
| 419 | uint8_t local_sap, xx; |
| 420 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 421 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 422 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 423 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 424 | local_sap = p_data->disconnect_resp.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 425 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 426 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 427 | if (p_data->disconnect_resp.reason == LLCP_SAP_DM_REASON_RESP_DISC) { |
| 428 | evt_data.disc.reason = NFA_P2P_DISC_REASON_LOCAL_INITITATE; |
| 429 | } else if ((p_data->disconnect_resp.reason == |
| 430 | LLCP_SAP_DM_REASON_APP_REJECTED) || |
| 431 | (p_data->disconnect_resp.reason == |
| 432 | LLCP_SAP_DM_REASON_PERM_REJECT_THIS) || |
| 433 | (p_data->disconnect_resp.reason == |
| 434 | LLCP_SAP_DM_REASON_PERM_REJECT_ANY) || |
| 435 | (p_data->disconnect_resp.reason == |
| 436 | LLCP_SAP_DM_REASON_TEMP_REJECT_THIS) || |
| 437 | (p_data->disconnect_resp.reason == |
| 438 | LLCP_SAP_DM_REASON_TEMP_REJECT_ANY)) { |
| 439 | evt_data.disc.reason = NFA_P2P_DISC_REASON_REMOTE_REJECT; |
| 440 | } else if (p_data->disconnect_resp.reason == |
| 441 | LLCP_SAP_DM_REASON_NO_SERVICE) { |
| 442 | evt_data.disc.reason = NFA_P2P_DISC_REASON_NO_SERVICE; |
| 443 | } else if (p_data->disconnect_resp.reason == |
| 444 | LLCP_SAP_DM_REASON_NO_ACTIVE_CONNECTION) { |
| 445 | evt_data.disc.reason = NFA_P2P_DISC_REASON_LLCP_DEACTIVATED; |
| 446 | } else { |
| 447 | evt_data.disc.reason = NFA_P2P_DISC_REASON_NO_INFORMATION; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 448 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 449 | |
| 450 | if (evt_data.disc.reason == NFA_P2P_DISC_REASON_LOCAL_INITITATE) { |
| 451 | xx = nfa_p2p_find_conn_cb(p_data->disconnect_resp.local_sap, |
| 452 | p_data->disconnect_resp.remote_sap); |
| 453 | |
| 454 | if (xx != LLCP_MAX_DATA_LINK) { |
| 455 | evt_data.disc.handle = |
| 456 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 457 | |
| 458 | nfa_p2p_deallocate_conn_cb(xx); |
| 459 | |
| 460 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
| 461 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 462 | LOG(ERROR) << StringPrintf("No connection found"); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 463 | } |
| 464 | } else { |
| 465 | evt_data.disc.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 466 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
| 467 | } |
| 468 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | /******************************************************************************* |
| 472 | ** |
| 473 | ** Function nfa_p2p_proc_llcp_congest |
| 474 | ** |
| 475 | ** Description Processing LLCP congestion event |
| 476 | ** |
| 477 | ** |
| 478 | ** Returns None |
| 479 | ** |
| 480 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 481 | void nfa_p2p_proc_llcp_congestion(tLLCP_SAP_CBACK_DATA* p_data) { |
| 482 | uint8_t local_sap, remote_sap, xx; |
| 483 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 484 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 485 | local_sap = p_data->congest.local_sap; |
| 486 | remote_sap = p_data->congest.remote_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 487 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 488 | evt_data.congest.link_type = p_data->congest.link_type; |
| 489 | evt_data.congest.is_congested = p_data->congest.is_congested; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 490 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 491 | if (p_data->congest.is_congested) { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 492 | DLOG_IF(INFO, nfc_debug_enabled) |
| 493 | << StringPrintf("START SAP=(0x%x,0x%x)", local_sap, remote_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 494 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 495 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 496 | DLOG_IF(INFO, nfc_debug_enabled) |
| 497 | << StringPrintf("END SAP=(0x%x,0x%x)", local_sap, remote_sap); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 498 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 499 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 500 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 501 | if (evt_data.congest.link_type == NFA_P2P_LLINK_TYPE) { |
| 502 | evt_data.congest.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 503 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 504 | if ((evt_data.congest.is_congested == false) && |
| 505 | (nfa_p2p_cb.sap_cb[local_sap].flags & |
| 506 | NFA_P2P_SAP_FLAG_LLINK_CONGESTED)) { |
| 507 | nfa_p2p_cb.sap_cb[local_sap].flags &= ~NFA_P2P_SAP_FLAG_LLINK_CONGESTED; |
| 508 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONGEST_EVT, &evt_data); |
| 509 | } else if ((evt_data.congest.is_congested == true) && |
| 510 | (!(nfa_p2p_cb.sap_cb[local_sap].flags & |
| 511 | NFA_P2P_SAP_FLAG_LLINK_CONGESTED))) { |
| 512 | /* this is overall congestion due to high usage of buffer pool */ |
| 513 | nfa_p2p_cb.sap_cb[local_sap].flags |= NFA_P2P_SAP_FLAG_LLINK_CONGESTED; |
| 514 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONGEST_EVT, &evt_data); |
| 515 | } |
| 516 | } else { |
| 517 | xx = nfa_p2p_find_conn_cb(local_sap, remote_sap); |
| 518 | |
| 519 | if (xx != LLCP_MAX_DATA_LINK) { |
| 520 | evt_data.congest.handle = |
| 521 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 522 | |
| 523 | if ((evt_data.congest.is_congested == false) && |
| 524 | (nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_CONGESTED)) { |
| 525 | nfa_p2p_cb.conn_cb[xx].flags &= ~NFA_P2P_CONN_FLAG_CONGESTED; |
| 526 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONGEST_EVT, &evt_data); |
| 527 | } else if ((evt_data.congest.is_congested == true) && |
| 528 | (!(nfa_p2p_cb.conn_cb[xx].flags & |
| 529 | NFA_P2P_CONN_FLAG_CONGESTED))) { |
| 530 | /* this is overall congestion due to high usage of buffer pool */ |
| 531 | nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_CONGESTED; |
| 532 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONGEST_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 533 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 534 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 535 | LOG(ERROR) << StringPrintf("No connection found"); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 536 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 537 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 538 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | /******************************************************************************* |
| 542 | ** |
| 543 | ** Function nfa_p2p_proc_llcp_link_status |
| 544 | ** |
| 545 | ** Description Processing LLCP link status |
| 546 | ** |
| 547 | ** |
| 548 | ** Returns next state after processing this event |
| 549 | ** |
| 550 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 551 | void nfa_p2p_proc_llcp_link_status(tLLCP_SAP_CBACK_DATA* p_data) { |
| 552 | uint8_t local_sap, xx; |
| 553 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 554 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 555 | DLOG_IF(INFO, nfc_debug_enabled) |
| 556 | << StringPrintf("is_activated:%d", p_data->link_status.is_activated); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 557 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 558 | local_sap = p_data->link_status.local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 559 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 560 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 561 | if (p_data->link_status.is_activated) { |
| 562 | /* only for server */ |
| 563 | evt_data.activated.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 564 | evt_data.activated.local_link_miu = nfa_p2p_cb.local_link_miu; |
| 565 | evt_data.activated.remote_link_miu = nfa_p2p_cb.remote_link_miu; |
| 566 | |
| 567 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_ACTIVATED_EVT, &evt_data); |
| 568 | } else /* if LLCP link is deactivated */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 569 | { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 570 | for (xx = 0; xx < LLCP_MAX_DATA_LINK; xx++) { |
| 571 | if ((nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_IN_USE) && |
| 572 | (nfa_p2p_cb.conn_cb[xx].local_sap == local_sap)) { |
| 573 | evt_data.disc.handle = |
| 574 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 575 | evt_data.disc.reason = NFA_P2P_DISC_REASON_LLCP_DEACTIVATED; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 576 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 577 | nfa_p2p_deallocate_conn_cb(xx); |
| 578 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 579 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 580 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 581 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 582 | /* notify deactivation and clear flags */ |
| 583 | if (nfa_p2p_cb.sap_cb[local_sap].flags & NFA_P2P_SAP_FLAG_SERVER) { |
| 584 | evt_data.deactivated.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 585 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DEACTIVATED_EVT, |
| 586 | &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 587 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 588 | nfa_p2p_cb.sap_cb[local_sap].flags = NFA_P2P_SAP_FLAG_SERVER; |
| 589 | } else if (nfa_p2p_cb.sap_cb[local_sap].flags & NFA_P2P_SAP_FLAG_CLIENT) { |
| 590 | evt_data.deactivated.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 591 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DEACTIVATED_EVT, |
| 592 | &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 593 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 594 | nfa_p2p_cb.sap_cb[local_sap].flags = NFA_P2P_SAP_FLAG_CLIENT; |
| 595 | } else /* if this is not registered service */ |
| 596 | { |
| 597 | nfa_p2p_cb.sap_cb[local_sap].p_cback = NULL; |
| 598 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 599 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 600 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | /******************************************************************************* |
| 604 | ** |
| 605 | ** Function nfa_p2p_reg_server |
| 606 | ** |
| 607 | ** Description Allocate a service as server and register to LLCP |
| 608 | ** |
| 609 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 610 | ** Returns FALSE if need to keep buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 611 | ** |
| 612 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 613 | bool nfa_p2p_reg_server(tNFA_P2P_MSG* p_msg) { |
| 614 | tNFA_P2P_EVT_DATA evt_data; |
| 615 | uint8_t server_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 616 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 617 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 618 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 619 | server_sap = LLCP_RegisterServer( |
| 620 | p_msg->api_reg_server.server_sap, p_msg->api_reg_server.link_type, |
| 621 | p_msg->api_reg_server.service_name, nfa_p2p_llcp_cback); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 622 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 623 | if (server_sap == LLCP_INVALID_SAP) { |
| 624 | evt_data.reg_server.server_handle = NFA_HANDLE_INVALID; |
| 625 | evt_data.reg_server.server_sap = NFA_P2P_INVALID_SAP; |
| 626 | strncpy(evt_data.reg_server.service_name, |
| 627 | p_msg->api_reg_server.service_name, LLCP_MAX_SN_LEN); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 628 | evt_data.reg_server.service_name[LLCP_MAX_SN_LEN] = 0; |
| 629 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 630 | p_msg->api_reg_server.p_cback(NFA_P2P_REG_SERVER_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 631 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 632 | return true; |
| 633 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 634 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 635 | /* if need to update WKS in LLCP Gen bytes */ |
| 636 | if (server_sap <= LLCP_UPPER_BOUND_WK_SAP) { |
| 637 | nfa_p2p_enable_listening(NFA_ID_P2P, true); |
| 638 | } else if (!nfa_p2p_cb.is_p2p_listening) { |
| 639 | nfa_p2p_enable_listening(NFA_ID_P2P, false); |
| 640 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 641 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 642 | nfa_p2p_cb.sap_cb[server_sap].p_cback = p_msg->api_reg_server.p_cback; |
| 643 | nfa_p2p_cb.sap_cb[server_sap].flags = NFA_P2P_SAP_FLAG_SERVER; |
| 644 | |
| 645 | evt_data.reg_server.server_handle = (NFA_HANDLE_GROUP_P2P | server_sap); |
| 646 | evt_data.reg_server.server_sap = server_sap; |
| 647 | strncpy(evt_data.reg_server.service_name, p_msg->api_reg_server.service_name, |
| 648 | LLCP_MAX_SN_LEN); |
| 649 | evt_data.reg_server.service_name[LLCP_MAX_SN_LEN] = 0; |
| 650 | |
| 651 | /* notify NFA_P2P_REG_SERVER_EVT to server */ |
| 652 | nfa_p2p_cb.sap_cb[server_sap].p_cback(NFA_P2P_REG_SERVER_EVT, &evt_data); |
| 653 | |
| 654 | /* if LLCP is already activated */ |
| 655 | if (nfa_p2p_cb.llcp_state == NFA_P2P_LLCP_STATE_ACTIVATED) { |
| 656 | evt_data.activated.handle = (NFA_HANDLE_GROUP_P2P | server_sap); |
| 657 | evt_data.activated.local_link_miu = nfa_p2p_cb.local_link_miu; |
| 658 | evt_data.activated.remote_link_miu = nfa_p2p_cb.remote_link_miu; |
| 659 | |
| 660 | /* notify NFA_P2P_ACTIVATED_EVT to server */ |
| 661 | nfa_p2p_cb.sap_cb[server_sap].p_cback(NFA_P2P_ACTIVATED_EVT, &evt_data); |
| 662 | } |
| 663 | |
| 664 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /******************************************************************************* |
| 668 | ** |
| 669 | ** Function nfa_p2p_reg_client |
| 670 | ** |
| 671 | ** Description Allocate a service as client and register to LLCP |
| 672 | ** |
| 673 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 674 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 675 | ** |
| 676 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 677 | bool nfa_p2p_reg_client(tNFA_P2P_MSG* p_msg) { |
| 678 | tNFA_P2P_EVT_DATA evt_data; |
| 679 | uint8_t local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 680 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 681 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 682 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 683 | local_sap = |
| 684 | LLCP_RegisterClient(p_msg->api_reg_client.link_type, nfa_p2p_llcp_cback); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 685 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 686 | if (local_sap == LLCP_INVALID_SAP) { |
| 687 | evt_data.reg_client.client_handle = NFA_HANDLE_INVALID; |
| 688 | p_msg->api_reg_client.p_cback(NFA_P2P_REG_CLIENT_EVT, &evt_data); |
| 689 | return true; |
| 690 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 691 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 692 | nfa_p2p_cb.sap_cb[local_sap].p_cback = p_msg->api_reg_client.p_cback; |
| 693 | nfa_p2p_cb.sap_cb[local_sap].flags = NFA_P2P_SAP_FLAG_CLIENT; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 694 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 695 | evt_data.reg_client.client_handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 696 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_REG_CLIENT_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 697 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 698 | /* if LLCP is already activated */ |
| 699 | if (nfa_p2p_cb.llcp_state == NFA_P2P_LLCP_STATE_ACTIVATED) { |
| 700 | evt_data.activated.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 701 | evt_data.activated.local_link_miu = nfa_p2p_cb.local_link_miu; |
| 702 | evt_data.activated.remote_link_miu = nfa_p2p_cb.remote_link_miu; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 703 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 704 | /* notify NFA_P2P_ACTIVATED_EVT to client */ |
| 705 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_ACTIVATED_EVT, &evt_data); |
| 706 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 707 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 708 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | /******************************************************************************* |
| 712 | ** |
| 713 | ** Function nfa_p2p_dereg |
| 714 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 715 | ** Description Deallocate a service as server or client and deregister to |
| 716 | ** LLCP. LLCP will deallocate data link connection created by |
| 717 | ** this server |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 718 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 719 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 720 | ** |
| 721 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 722 | bool nfa_p2p_dereg(tNFA_P2P_MSG* p_msg) { |
| 723 | uint8_t local_sap, xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 724 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 725 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 726 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 727 | local_sap = (uint8_t)(p_msg->api_dereg.handle & NFA_HANDLE_MASK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 728 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 729 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 730 | for (xx = 0; xx < LLCP_MAX_DATA_LINK; xx++) { |
| 731 | if ((nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_IN_USE) && |
| 732 | (nfa_p2p_cb.conn_cb[xx].local_sap == local_sap)) { |
| 733 | nfa_p2p_deallocate_conn_cb(xx); |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | LLCP_Deregister(local_sap); |
| 739 | nfa_p2p_cb.sap_cb[local_sap].p_cback = NULL; |
| 740 | |
| 741 | if (nfa_p2p_cb.is_p2p_listening) { |
| 742 | /* check if this is the last server on NFA P2P */ |
| 743 | for (xx = 0; xx < NFA_P2P_NUM_SAP; xx++) { |
| 744 | if ((nfa_p2p_cb.sap_cb[xx].p_cback) && |
| 745 | (nfa_p2p_cb.sap_cb[xx].flags & NFA_P2P_SAP_FLAG_SERVER)) { |
| 746 | break; |
| 747 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 748 | } |
| 749 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 750 | if (xx >= NFA_P2P_NUM_SAP) { |
| 751 | /* if need to update WKS in LLCP Gen bytes */ |
| 752 | if (local_sap <= LLCP_UPPER_BOUND_WK_SAP) |
| 753 | nfa_p2p_disable_listening(NFA_ID_P2P, true); |
| 754 | else |
| 755 | nfa_p2p_disable_listening(NFA_ID_P2P, false); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 756 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 757 | /* if need to update WKS in LLCP Gen bytes */ |
| 758 | else if (local_sap <= LLCP_UPPER_BOUND_WK_SAP) { |
| 759 | nfa_p2p_enable_listening(NFA_ID_P2P, true); |
| 760 | } |
| 761 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 762 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 763 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | /******************************************************************************* |
| 767 | ** |
| 768 | ** Function nfa_p2p_accept_connection |
| 769 | ** |
| 770 | ** Description Connection Confirm from local application |
| 771 | ** |
| 772 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 773 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 774 | ** |
| 775 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 776 | bool nfa_p2p_accept_connection(tNFA_P2P_MSG* p_msg) { |
| 777 | uint8_t xx; |
| 778 | tLLCP_CONNECTION_PARAMS params; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 779 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 780 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 781 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 782 | xx = (uint8_t)(p_msg->api_accept.conn_handle & NFA_HANDLE_MASK); |
| 783 | xx &= ~NFA_P2P_HANDLE_FLAG_CONN; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 784 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 785 | params.miu = p_msg->api_accept.miu; |
| 786 | params.rw = p_msg->api_accept.rw; |
| 787 | params.sn[0] = 0; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 788 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 789 | LLCP_ConnectCfm(nfa_p2p_cb.conn_cb[xx].local_sap, |
| 790 | nfa_p2p_cb.conn_cb[xx].remote_sap, ¶ms); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 791 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 792 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | /******************************************************************************* |
| 796 | ** |
| 797 | ** Function nfa_p2p_reject_connection |
| 798 | ** |
| 799 | ** Description Reject connection by local application |
| 800 | ** |
| 801 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 802 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 803 | ** |
| 804 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 805 | bool nfa_p2p_reject_connection(tNFA_P2P_MSG* p_msg) { |
| 806 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 807 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 808 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 809 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 810 | xx = (uint8_t)(p_msg->api_reject.conn_handle & NFA_HANDLE_MASK); |
| 811 | xx &= ~NFA_P2P_HANDLE_FLAG_CONN; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 812 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 813 | LLCP_ConnectReject(nfa_p2p_cb.conn_cb[xx].local_sap, |
| 814 | nfa_p2p_cb.conn_cb[xx].remote_sap, |
| 815 | LLCP_SAP_DM_REASON_APP_REJECTED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 816 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 817 | /* no need to deregister service on LLCP */ |
| 818 | nfa_p2p_deallocate_conn_cb(xx); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 819 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 820 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | /******************************************************************************* |
| 824 | ** |
| 825 | ** Function nfa_p2p_disconnect |
| 826 | ** |
| 827 | ** Description Disconnect data link connection by local application |
| 828 | ** |
| 829 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 830 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 831 | ** |
| 832 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 833 | bool nfa_p2p_disconnect(tNFA_P2P_MSG* p_msg) { |
| 834 | uint8_t local_sap, xx; |
| 835 | tLLCP_STATUS status; |
| 836 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 837 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 838 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 839 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 840 | xx = (uint8_t)(p_msg->api_disconnect.conn_handle & NFA_HANDLE_MASK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 841 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 842 | /* if this is for data link connection */ |
| 843 | if (xx & NFA_P2P_HANDLE_FLAG_CONN) { |
| 844 | xx &= ~NFA_P2P_HANDLE_FLAG_CONN; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 845 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 846 | status = LLCP_DisconnectReq(nfa_p2p_cb.conn_cb[xx].local_sap, |
| 847 | nfa_p2p_cb.conn_cb[xx].remote_sap, |
| 848 | p_msg->api_disconnect.flush); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 849 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 850 | if (status == LLCP_STATUS_SUCCESS) { |
| 851 | /* wait for disconnect response if successful */ |
| 852 | return true; |
| 853 | } else { |
| 854 | /* |
| 855 | ** while we are waiting for connect confirm, |
| 856 | ** we cannot sent DISC because we don't know DSAP yet |
| 857 | */ |
| 858 | local_sap = nfa_p2p_cb.conn_cb[xx].local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 859 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 860 | if (nfa_p2p_cb.sap_cb[local_sap].p_cback) { |
| 861 | evt_data.disc.handle = |
| 862 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 863 | evt_data.disc.reason = NFA_P2P_DISC_REASON_LOCAL_INITITATE; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 864 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 865 | nfa_p2p_deallocate_conn_cb(xx); |
| 866 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
| 867 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 868 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 869 | } else { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 870 | LOG(ERROR) << StringPrintf("Handle is not for Data link connection"); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 871 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 872 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 873 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | /******************************************************************************* |
| 877 | ** |
| 878 | ** Function nfa_p2p_create_data_link_connection |
| 879 | ** |
| 880 | ** Description Create data link connection |
| 881 | ** |
| 882 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 883 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 884 | ** |
| 885 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 886 | bool nfa_p2p_create_data_link_connection(tNFA_P2P_MSG* p_msg) { |
| 887 | uint8_t local_sap; |
| 888 | tNFA_P2P_EVT_DATA evt_data; |
| 889 | tLLCP_CONNECTION_PARAMS conn_params; |
| 890 | tLLCP_STATUS status; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 891 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 892 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 893 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 894 | local_sap = (uint8_t)(p_msg->api_connect.client_handle & NFA_HANDLE_MASK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 895 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 896 | conn_params.miu = p_msg->api_connect.miu; |
| 897 | conn_params.rw = p_msg->api_connect.rw; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 898 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 899 | /* NFA_P2pConnectBySap () */ |
| 900 | if (p_msg->api_connect.dsap != LLCP_INVALID_SAP) { |
| 901 | conn_params.sn[0] = 0; |
| 902 | status = LLCP_ConnectReq(local_sap, p_msg->api_connect.dsap, &conn_params); |
| 903 | } |
| 904 | /* NFA_P2pConnectByName () */ |
| 905 | else { |
| 906 | strncpy(conn_params.sn, p_msg->api_connect.service_name, LLCP_MAX_SN_LEN); |
| 907 | conn_params.sn[LLCP_MAX_SN_LEN] = 0; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 908 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 909 | status = LLCP_ConnectReq(local_sap, LLCP_SAP_SDP, &conn_params); |
| 910 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 911 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 912 | if (status != LLCP_STATUS_SUCCESS) { |
| 913 | evt_data.disc.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 914 | evt_data.disc.reason = NFA_P2P_DISC_REASON_NO_INFORMATION; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 915 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 916 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_DISC_EVT, &evt_data); |
| 917 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 918 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 919 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | /******************************************************************************* |
| 923 | ** |
| 924 | ** Function nfa_p2p_send_ui |
| 925 | ** |
| 926 | ** Description Send UI PDU |
| 927 | ** |
| 928 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 929 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 930 | ** |
| 931 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 932 | bool nfa_p2p_send_ui(tNFA_P2P_MSG* p_msg) { |
| 933 | uint8_t local_sap; |
| 934 | tLLCP_STATUS status; |
| 935 | tNFA_P2P_EVT_DATA evt_data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 936 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 937 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 938 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 939 | local_sap = (uint8_t)(p_msg->api_send_ui.handle & NFA_HANDLE_MASK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 940 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 941 | /* decrease number of tx UI PDU which is not processed by NFA for congestion |
| 942 | * control */ |
| 943 | if (nfa_p2p_cb.sap_cb[local_sap].num_pending_ui_pdu) |
| 944 | nfa_p2p_cb.sap_cb[local_sap].num_pending_ui_pdu--; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 945 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 946 | if (nfa_p2p_cb.total_pending_ui_pdu) nfa_p2p_cb.total_pending_ui_pdu--; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 947 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 948 | status = |
| 949 | LLCP_SendUI(local_sap, p_msg->api_send_ui.dsap, p_msg->api_send_ui.p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 950 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 951 | if (status == LLCP_STATUS_CONGESTED) { |
| 952 | if (!(nfa_p2p_cb.sap_cb[local_sap].flags & |
| 953 | NFA_P2P_SAP_FLAG_LLINK_CONGESTED)) { |
| 954 | nfa_p2p_cb.sap_cb[local_sap].flags |= NFA_P2P_SAP_FLAG_LLINK_CONGESTED; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 955 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 956 | /* notify that this logical link is congested */ |
| 957 | evt_data.congest.link_type = NFA_P2P_LLINK_TYPE; |
| 958 | evt_data.congest.handle = (NFA_HANDLE_GROUP_P2P | local_sap); |
| 959 | evt_data.congest.is_congested = true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 960 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 961 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_CONGEST_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 962 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 963 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 964 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 965 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | /******************************************************************************* |
| 969 | ** |
| 970 | ** Function nfa_p2p_send_data |
| 971 | ** |
| 972 | ** Description Send I PDU |
| 973 | ** |
| 974 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 975 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 976 | ** |
| 977 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 978 | bool nfa_p2p_send_data(tNFA_P2P_MSG* p_msg) { |
| 979 | tNFA_P2P_EVT_DATA evt_data; |
| 980 | tLLCP_STATUS status; |
| 981 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 982 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 983 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 984 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 985 | xx = (uint8_t)(p_msg->api_send_data.conn_handle & NFA_HANDLE_MASK); |
| 986 | xx &= ~NFA_P2P_HANDLE_FLAG_CONN; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 987 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 988 | /* decrease number of tx I PDU which is not processed by NFA for congestion |
| 989 | * control */ |
| 990 | if (nfa_p2p_cb.conn_cb[xx].num_pending_i_pdu) |
| 991 | nfa_p2p_cb.conn_cb[xx].num_pending_i_pdu--; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 992 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 993 | if (nfa_p2p_cb.total_pending_i_pdu) nfa_p2p_cb.total_pending_i_pdu--; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 994 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 995 | status = LLCP_SendData(nfa_p2p_cb.conn_cb[xx].local_sap, |
| 996 | nfa_p2p_cb.conn_cb[xx].remote_sap, |
| 997 | p_msg->api_send_data.p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 998 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 999 | if (status == LLCP_STATUS_CONGESTED) { |
| 1000 | if (!(nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_CONGESTED)) { |
| 1001 | nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_CONGESTED; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1002 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1003 | /* notify that this data link is congested */ |
| 1004 | evt_data.congest.link_type = NFA_P2P_DLINK_TYPE; |
| 1005 | evt_data.congest.handle = |
| 1006 | (NFA_HANDLE_GROUP_P2P | NFA_P2P_HANDLE_FLAG_CONN | xx); |
| 1007 | evt_data.congest.is_congested = true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1008 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1009 | nfa_p2p_cb.sap_cb[nfa_p2p_cb.conn_cb[xx].local_sap].p_cback( |
| 1010 | NFA_P2P_CONGEST_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1011 | } |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1012 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1013 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1014 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | /******************************************************************************* |
| 1018 | ** |
| 1019 | ** Function nfa_p2p_set_local_busy |
| 1020 | ** |
| 1021 | ** Description Set or reset local busy |
| 1022 | ** |
| 1023 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1024 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1025 | ** |
| 1026 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1027 | bool nfa_p2p_set_local_busy(tNFA_P2P_MSG* p_msg) { |
| 1028 | uint8_t xx; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1029 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1030 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1031 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1032 | xx = (uint8_t)(p_msg->api_local_busy.conn_handle & NFA_HANDLE_MASK); |
| 1033 | xx &= ~NFA_P2P_HANDLE_FLAG_CONN; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1034 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1035 | LLCP_SetLocalBusyStatus(nfa_p2p_cb.conn_cb[xx].local_sap, |
| 1036 | nfa_p2p_cb.conn_cb[xx].remote_sap, |
| 1037 | p_msg->api_local_busy.is_busy); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1038 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1039 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | /******************************************************************************* |
| 1043 | ** |
| 1044 | ** Function nfa_p2p_get_link_info |
| 1045 | ** |
| 1046 | ** Description Get WKS of remote and link MIU |
| 1047 | ** |
| 1048 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1049 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1050 | ** |
| 1051 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1052 | bool nfa_p2p_get_link_info(tNFA_P2P_MSG* p_msg) { |
| 1053 | tNFA_P2P_EVT_DATA evt_data; |
| 1054 | uint8_t local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1055 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1056 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1057 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1058 | evt_data.link_info.handle = p_msg->api_link_info.handle; |
| 1059 | evt_data.link_info.wks = LLCP_GetRemoteWKS(); |
| 1060 | evt_data.link_info.local_link_miu = nfa_p2p_cb.local_link_miu; |
| 1061 | evt_data.link_info.remote_link_miu = nfa_p2p_cb.remote_link_miu; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1062 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1063 | local_sap = (uint8_t)(p_msg->api_link_info.handle & NFA_HANDLE_MASK); |
| 1064 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_LINK_INFO_EVT, &evt_data); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1065 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1066 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1067 | } |
| 1068 | |
| 1069 | /******************************************************************************* |
| 1070 | ** |
| 1071 | ** Function nfa_p2p_get_remote_sap |
| 1072 | ** |
| 1073 | ** Description Get remote SAP |
| 1074 | ** |
| 1075 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1076 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1077 | ** |
| 1078 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1079 | bool nfa_p2p_get_remote_sap(tNFA_P2P_MSG* p_msg) { |
| 1080 | tNFA_P2P_EVT_DATA evt_data; |
| 1081 | uint8_t local_sap; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1082 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1083 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1084 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1085 | local_sap = (uint8_t)(p_msg->api_remote_sap.handle & NFA_HANDLE_MASK); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1086 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1087 | if (!nfa_p2p_start_sdp(p_msg->api_remote_sap.service_name, local_sap)) { |
| 1088 | evt_data.sdp.handle = p_msg->api_remote_sap.handle; |
| 1089 | evt_data.sdp.remote_sap = 0x00; |
| 1090 | nfa_p2p_cb.sap_cb[local_sap].p_cback(NFA_P2P_SDP_EVT, &evt_data); |
| 1091 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1092 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1093 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | /******************************************************************************* |
| 1097 | ** |
| 1098 | ** Function nfa_p2p_set_llcp_cfg |
| 1099 | ** |
| 1100 | ** Description Set LLCP configuration |
| 1101 | ** |
| 1102 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1103 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1104 | ** |
| 1105 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1106 | bool nfa_p2p_set_llcp_cfg(tNFA_P2P_MSG* p_msg) { |
| 1107 | LLCP_SetConfig(p_msg->api_set_llcp_cfg.link_miu, p_msg->api_set_llcp_cfg.opt, |
| 1108 | p_msg->api_set_llcp_cfg.wt, |
| 1109 | p_msg->api_set_llcp_cfg.link_timeout, |
| 1110 | p_msg->api_set_llcp_cfg.inact_timeout_init, |
| 1111 | p_msg->api_set_llcp_cfg.inact_timeout_target, |
| 1112 | p_msg->api_set_llcp_cfg.symm_delay, |
| 1113 | p_msg->api_set_llcp_cfg.data_link_timeout, |
| 1114 | p_msg->api_set_llcp_cfg.delay_first_pdu_timeout); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1115 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1116 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | /******************************************************************************* |
| 1120 | ** |
| 1121 | ** Function nfa_p2p_restart_rf_discovery |
| 1122 | ** |
| 1123 | ** Description Restart RF discovery by deactivating to IDLE |
| 1124 | ** |
| 1125 | ** |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1126 | ** Returns TRUE to deallocate buffer |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1127 | ** |
| 1128 | *******************************************************************************/ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1129 | bool nfa_p2p_restart_rf_discovery(__attribute__((unused)) tNFA_P2P_MSG* p_msg) { |
| 1130 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1131 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1132 | nfa_dm_rf_deactivate(NFA_DEACTIVATE_TYPE_IDLE); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1133 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1134 | return true; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1135 | } |