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 * NFA interface to LLCP
22 *
23 ******************************************************************************/
24 #include <string.h>
25 #include "nfc_api.h"
26 #include "nfa_sys.h"
27 #include "nfa_sys_int.h"
28 #include "llcp_defs.h"
29 #include "llcp_api.h"
30 #include "nfa_p2p_api.h"
31 #include "nfa_p2p_int.h"
32
33 /*****************************************************************************
34 ** Constants
35 *****************************************************************************/
36
37 /*******************************************************************************
38 **
39 ** Function NFA_P2pRegisterServer
40 **
41 ** Description This function is called to listen to a SAP as server on LLCP.
42 **
43 ** NFA_P2P_REG_SERVER_EVT will be returned with status and handle.
44 **
45 ** If server_sap is set to NFA_P2P_ANY_SAP, then NFA will allocate
46 ** a SAP between LLCP_LOWER_BOUND_SDP_SAP and LLCP_UPPER_BOUND_SDP_SAP
47 ** Otherwise, server_sap must be between (LLCP_SDP_SAP + 1) and
48 ** LLCP_UPPER_BOUND_SDP_SAP
49 **
50 ** link_type : NFA_P2P_LLINK_TYPE and/or NFA_P2P_DLINK_TYPE
51 **
52 ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
53 ** should happen before calling this function
54 **
55 ** Returns NFA_STATUS_OK if successfully initiated
56 ** NFA_STATUS_FAILED otherwise
57 **
58 *******************************************************************************/
NFA_P2pRegisterServer(UINT8 server_sap,tNFA_P2P_LINK_TYPE link_type,char * p_service_name,tNFA_P2P_CBACK * p_cback)59 tNFA_STATUS NFA_P2pRegisterServer (UINT8 server_sap,
60 tNFA_P2P_LINK_TYPE link_type,
61 char *p_service_name,
62 tNFA_P2P_CBACK *p_cback)
63 {
64 tNFA_P2P_API_REG_SERVER *p_msg;
65
66 P2P_TRACE_API3 ("NFA_P2pRegisterServer (): server_sap:0x%02x, link_type:0x%x, SN:<%s>",
67 server_sap, link_type, p_service_name);
68
69 if ( (server_sap != NFA_P2P_ANY_SAP)
70 &&((server_sap <= LLCP_SAP_SDP) ||(server_sap > LLCP_UPPER_BOUND_SDP_SAP)) )
71 {
72 P2P_TRACE_ERROR2 ("NFA_P2pRegisterServer (): server_sap must be between %d and %d",
73 LLCP_SAP_SDP + 1, LLCP_UPPER_BOUND_SDP_SAP);
74 return (NFA_STATUS_FAILED);
75 }
76 else if ( ((link_type & NFA_P2P_LLINK_TYPE) == 0x00)
77 &&((link_type & NFA_P2P_DLINK_TYPE) == 0x00) )
78 {
79 P2P_TRACE_ERROR1 ("NFA_P2pRegisterServer(): link type (0x%x) must be specified", link_type);
80 return (NFA_STATUS_FAILED);
81 }
82
83 if ((p_msg = (tNFA_P2P_API_REG_SERVER *) GKI_getbuf (sizeof (tNFA_P2P_API_REG_SERVER))) != NULL)
84 {
85 p_msg->hdr.event = NFA_P2P_API_REG_SERVER_EVT;
86
87 p_msg->server_sap = server_sap;
88 p_msg->link_type = link_type;
89
90 BCM_STRNCPY_S (p_msg->service_name, sizeof (p_msg->service_name), p_service_name, LLCP_MAX_SN_LEN);
91 p_msg->service_name[LLCP_MAX_SN_LEN] = 0;
92
93 p_msg->p_cback = p_cback;
94
95 nfa_sys_sendmsg (p_msg);
96
97 return (NFA_STATUS_OK);
98 }
99
100 return (NFA_STATUS_FAILED);
101 }
102
103 /*******************************************************************************
104 **
105 ** Function NFA_P2pRegisterClient
106 **
107 ** Description This function is called to register a client service on LLCP.
108 **
109 ** NFA_P2P_REG_CLIENT_EVT will be returned with status and handle.
110 **
111 ** link_type : NFA_P2P_LLINK_TYPE and/or NFA_P2P_DLINK_TYPE
112 **
113 ** Returns NFA_STATUS_OK if successfully initiated
114 ** NFA_STATUS_FAILED otherwise
115 **
116 *******************************************************************************/
NFA_P2pRegisterClient(tNFA_P2P_LINK_TYPE link_type,tNFA_P2P_CBACK * p_cback)117 tNFA_STATUS NFA_P2pRegisterClient (tNFA_P2P_LINK_TYPE link_type,
118 tNFA_P2P_CBACK *p_cback)
119 {
120 tNFA_P2P_API_REG_CLIENT *p_msg;
121
122 P2P_TRACE_API1 ("NFA_P2pRegisterClient (): link_type:0x%x", link_type);
123
124 if ( ((link_type & NFA_P2P_LLINK_TYPE) == 0x00)
125 &&((link_type & NFA_P2P_DLINK_TYPE) == 0x00) )
126 {
127 P2P_TRACE_ERROR1 ("NFA_P2pRegisterClient (): link type (0x%x) must be specified", link_type);
128 return (NFA_STATUS_FAILED);
129 }
130
131 if ((p_msg = (tNFA_P2P_API_REG_CLIENT *) GKI_getbuf (sizeof (tNFA_P2P_API_REG_CLIENT))) != NULL)
132 {
133 p_msg->hdr.event = NFA_P2P_API_REG_CLIENT_EVT;
134
135 p_msg->p_cback = p_cback;
136 p_msg->link_type = link_type;
137
138 nfa_sys_sendmsg (p_msg);
139
140 return (NFA_STATUS_OK);
141 }
142
143 return (NFA_STATUS_FAILED);
144 }
145
146 /*******************************************************************************
147 **
148 ** Function NFA_P2pDeregister
149 **
150 ** Description This function is called to stop listening to a SAP as server
151 ** or stop client service on LLCP.
152 **
153 ** Note: If this function is called to de-register a server and RF discovery
154 ** is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT
155 ** should happen before calling this function
156 **
157 ** Returns NFA_STATUS_OK if successfully initiated
158 ** NFA_STATUS_BAD_HANDLE if handle is not valid
159 ** NFA_STATUS_FAILED otherwise
160 **
161 *******************************************************************************/
NFA_P2pDeregister(tNFA_HANDLE handle)162 tNFA_STATUS NFA_P2pDeregister (tNFA_HANDLE handle)
163 {
164 tNFA_P2P_API_DEREG *p_msg;
165 tNFA_HANDLE xx;
166
167 P2P_TRACE_API1 ("NFA_P2pDeregister (): handle:0x%02X", handle);
168
169 xx = handle & NFA_HANDLE_MASK;
170
171 if ( (xx >= NFA_P2P_NUM_SAP)
172 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
173 {
174 P2P_TRACE_ERROR0 ("NFA_P2pDeregister (): Handle is invalid or not registered");
175 return (NFA_STATUS_BAD_HANDLE);
176 }
177
178 if ((p_msg = (tNFA_P2P_API_DEREG *) GKI_getbuf (sizeof (tNFA_P2P_API_DEREG))) != NULL)
179 {
180 p_msg->hdr.event = NFA_P2P_API_DEREG_EVT;
181
182 p_msg->handle = handle;
183
184 nfa_sys_sendmsg (p_msg);
185
186 return (NFA_STATUS_OK);
187 }
188
189 return (NFA_STATUS_FAILED);
190 }
191
192 /*******************************************************************************
193 **
194 ** Function NFA_P2pAcceptConn
195 **
196 ** Description This function is called to accept a request of data link
197 ** connection to a listening SAP on LLCP after receiving
198 ** NFA_P2P_CONN_REQ_EVT.
199 **
200 ** Returns NFA_STATUS_OK if successfully initiated
201 ** NFA_STATUS_BAD_HANDLE if handle is not valid
202 ** NFA_STATUS_FAILED otherwise
203 **
204 *******************************************************************************/
NFA_P2pAcceptConn(tNFA_HANDLE handle,UINT16 miu,UINT8 rw)205 tNFA_STATUS NFA_P2pAcceptConn (tNFA_HANDLE handle,
206 UINT16 miu,
207 UINT8 rw)
208 {
209 tNFA_P2P_API_ACCEPT_CONN *p_msg;
210 tNFA_HANDLE xx;
211
212 P2P_TRACE_API3 ("NFA_P2pAcceptConn (): handle:0x%02X, MIU:%d, RW:%d", handle, miu, rw);
213
214 xx = handle & NFA_HANDLE_MASK;
215
216 if (!(xx & NFA_P2P_HANDLE_FLAG_CONN))
217 {
218 P2P_TRACE_ERROR0 ("NFA_P2pAcceptConn (): Connection Handle is not valid");
219 return (NFA_STATUS_BAD_HANDLE);
220 }
221 else
222 {
223 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
224 }
225
226 if ( (xx >= LLCP_MAX_DATA_LINK)
227 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
228 {
229 P2P_TRACE_ERROR0 ("NFA_P2pAcceptConn (): Connection Handle is not valid");
230 return (NFA_STATUS_BAD_HANDLE);
231 }
232
233 if ((miu < LLCP_DEFAULT_MIU) || (nfa_p2p_cb.local_link_miu < miu))
234 {
235 P2P_TRACE_ERROR3 ("NFA_P2pAcceptConn (): MIU(%d) must be between %d and %d",
236 miu, LLCP_DEFAULT_MIU, nfa_p2p_cb.local_link_miu);
237 }
238 else if ((p_msg = (tNFA_P2P_API_ACCEPT_CONN *) GKI_getbuf (sizeof (tNFA_P2P_API_ACCEPT_CONN))) != NULL)
239 {
240 p_msg->hdr.event = NFA_P2P_API_ACCEPT_CONN_EVT;
241
242 p_msg->conn_handle = handle;
243 p_msg->miu = miu;
244 p_msg->rw = rw;
245
246 nfa_sys_sendmsg (p_msg);
247
248 return (NFA_STATUS_OK);
249 }
250
251 return (NFA_STATUS_FAILED);
252 }
253
254 /*******************************************************************************
255 **
256 ** Function NFA_P2pRejectConn
257 **
258 ** Description This function is called to reject a request of data link
259 ** connection to a listening SAP on LLCP after receiving
260 ** NFA_P2P_CONN_REQ_EVT.
261 **
262 ** Returns NFA_STATUS_OK if successfully initiated
263 ** NFA_STATUS_BAD_HANDLE if handle is not valid
264 ** NFA_STATUS_FAILED otherwise
265 **
266 *******************************************************************************/
NFA_P2pRejectConn(tNFA_HANDLE handle)267 tNFA_STATUS NFA_P2pRejectConn (tNFA_HANDLE handle)
268 {
269 tNFA_P2P_API_REJECT_CONN *p_msg;
270 tNFA_HANDLE xx;
271
272 P2P_TRACE_API1 ("NFA_P2pRejectConn (): handle:0x%02X", handle);
273
274 xx = handle & NFA_HANDLE_MASK;
275
276 if (!(xx & NFA_P2P_HANDLE_FLAG_CONN))
277 {
278 P2P_TRACE_ERROR0 ("NFA_P2pRejectConn (): Connection Handle is not valid");
279 return (NFA_STATUS_BAD_HANDLE);
280 }
281 else
282 {
283 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
284 }
285
286 if ( (xx >= LLCP_MAX_DATA_LINK)
287 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
288 {
289 P2P_TRACE_ERROR0 ("NFA_P2pRejectConn (): Connection Handle is not valid");
290 return (NFA_STATUS_BAD_HANDLE);
291 }
292
293 if ((p_msg = (tNFA_P2P_API_REJECT_CONN *) GKI_getbuf (sizeof (tNFA_P2P_API_REJECT_CONN))) != NULL)
294 {
295 p_msg->hdr.event = NFA_P2P_API_REJECT_CONN_EVT;
296
297 p_msg->conn_handle = handle;
298
299 nfa_sys_sendmsg (p_msg);
300
301 return (NFA_STATUS_OK);
302 }
303
304 return (NFA_STATUS_FAILED);
305 }
306
307 /*******************************************************************************
308 **
309 ** Function NFA_P2pDisconnect
310 **
311 ** Description This function is called to disconnect an existing or
312 ** connecting data link connection.
313 **
314 ** discard any pending data on data link connection if flush is set to TRUE
315 **
316 ** NFA_P2P_DISC_EVT will be returned after data link connection is disconnected
317 **
318 ** Returns NFA_STATUS_OK if successfully initiated
319 ** NFA_STATUS_BAD_HANDLE if handle is not valid
320 ** NFA_STATUS_FAILED otherwise
321 **
322 *******************************************************************************/
NFA_P2pDisconnect(tNFA_HANDLE handle,BOOLEAN flush)323 tNFA_STATUS NFA_P2pDisconnect (tNFA_HANDLE handle, BOOLEAN flush)
324 {
325 tNFA_P2P_API_DISCONNECT *p_msg;
326 tNFA_HANDLE xx;
327
328 P2P_TRACE_API2 ("NFA_P2pDisconnect (): handle:0x%02X, flush=%d", handle, flush);
329
330 xx = handle & NFA_HANDLE_MASK;
331
332 if (xx & NFA_P2P_HANDLE_FLAG_CONN)
333 {
334 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
335
336 if ( (xx >= LLCP_MAX_DATA_LINK)
337 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
338 {
339 P2P_TRACE_ERROR0 ("NFA_P2pDisconnect (): Connection Handle is not valid");
340 return (NFA_STATUS_BAD_HANDLE);
341 }
342 }
343 else
344 {
345 P2P_TRACE_ERROR0 ("NFA_P2pDisconnect (): Handle is not valid");
346 return (NFA_STATUS_BAD_HANDLE);
347 }
348
349 if ((p_msg = (tNFA_P2P_API_DISCONNECT *) GKI_getbuf (sizeof (tNFA_P2P_API_DISCONNECT))) != NULL)
350 {
351 p_msg->hdr.event = NFA_P2P_API_DISCONNECT_EVT;
352
353 p_msg->conn_handle = handle;
354 p_msg->flush = flush;
355
356 nfa_sys_sendmsg (p_msg);
357
358 return (NFA_STATUS_OK);
359 }
360
361 return (NFA_STATUS_FAILED);
362 }
363
364 /*******************************************************************************
365 **
366 ** Function NFA_P2pConnectByName
367 **
368 ** Description This function is called to create a connection-oriented transport
369 ** by a service name.
370 ** NFA_P2P_CONNECTED_EVT if success
371 ** NFA_P2P_DISC_EVT if failed
372 **
373 ** Returns NFA_STATUS_OK if successfully initiated
374 ** NFA_STATUS_BAD_HANDLE if client is not registered
375 ** NFA_STATUS_FAILED otherwise
376 **
377 *******************************************************************************/
NFA_P2pConnectByName(tNFA_HANDLE client_handle,char * p_service_name,UINT16 miu,UINT8 rw)378 tNFA_STATUS NFA_P2pConnectByName (tNFA_HANDLE client_handle,
379 char *p_service_name,
380 UINT16 miu,
381 UINT8 rw)
382 {
383 tNFA_P2P_API_CONNECT *p_msg;
384 tNFA_HANDLE xx;
385
386 P2P_TRACE_API4 ("NFA_P2pConnectByName (): client_handle:0x%x, SN:<%s>, MIU:%d, RW:%d",
387 client_handle, p_service_name, miu, rw);
388
389 xx = client_handle & NFA_HANDLE_MASK;
390
391 if ( (xx >= NFA_P2P_NUM_SAP)
392 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
393 {
394 P2P_TRACE_ERROR0 ("NFA_P2pConnectByName (): Client Handle is not valid");
395 return (NFA_STATUS_BAD_HANDLE);
396 }
397
398 if ( (miu < LLCP_DEFAULT_MIU)
399 ||(nfa_p2p_cb.llcp_state != NFA_P2P_LLCP_STATE_ACTIVATED)
400 ||(nfa_p2p_cb.local_link_miu < miu) )
401 {
402 P2P_TRACE_ERROR3 ("NFA_P2pConnectByName (): MIU(%d) must be between %d and %d or LLCP link is not activated",
403 miu, LLCP_DEFAULT_MIU, nfa_p2p_cb.local_link_miu);
404 }
405 else if ((p_msg = (tNFA_P2P_API_CONNECT *) GKI_getbuf (sizeof (tNFA_P2P_API_CONNECT))) != NULL)
406 {
407 p_msg->hdr.event = NFA_P2P_API_CONNECT_EVT;
408
409 BCM_STRNCPY_S (p_msg->service_name, sizeof (p_msg->service_name), p_service_name, LLCP_MAX_SN_LEN);
410 p_msg->service_name[LLCP_MAX_SN_LEN] = 0;
411
412 p_msg->dsap = LLCP_INVALID_SAP;
413 p_msg->miu = miu;
414 p_msg->rw = rw;
415 p_msg->client_handle = client_handle;
416
417 nfa_sys_sendmsg (p_msg);
418
419 return (NFA_STATUS_OK);
420 }
421
422 return (NFA_STATUS_FAILED);
423 }
424
425 /*******************************************************************************
426 **
427 ** Function NFA_P2pConnectBySap
428 **
429 ** Description This function is called to create a connection-oriented transport
430 ** by a SAP.
431 ** NFA_P2P_CONNECTED_EVT if success
432 ** NFA_P2P_DISC_EVT if failed
433 **
434 ** Returns NFA_STATUS_OK if successfully initiated
435 ** NFA_STATUS_BAD_HANDLE if client is not registered
436 ** NFA_STATUS_FAILED otherwise
437 **
438 *******************************************************************************/
NFA_P2pConnectBySap(tNFA_HANDLE client_handle,UINT8 dsap,UINT16 miu,UINT8 rw)439 tNFA_STATUS NFA_P2pConnectBySap (tNFA_HANDLE client_handle,
440 UINT8 dsap,
441 UINT16 miu,
442 UINT8 rw)
443 {
444 tNFA_P2P_API_CONNECT *p_msg;
445 tNFA_HANDLE xx;
446
447 P2P_TRACE_API4 ("NFA_P2pConnectBySap (): client_handle:0x%x, DSAP:0x%02X, MIU:%d, RW:%d",
448 client_handle, dsap, miu, rw);
449
450 xx = client_handle & NFA_HANDLE_MASK;
451
452 if ( (xx >= NFA_P2P_NUM_SAP)
453 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
454 {
455 P2P_TRACE_ERROR0 ("NFA_P2pConnectBySap (): Client Handle is not valid");
456 return (NFA_STATUS_BAD_HANDLE);
457 }
458
459 if ( (miu < LLCP_DEFAULT_MIU)
460 ||(nfa_p2p_cb.llcp_state != NFA_P2P_LLCP_STATE_ACTIVATED)
461 ||(nfa_p2p_cb.local_link_miu < miu) )
462 {
463 P2P_TRACE_ERROR3 ("NFA_P2pConnectBySap (): MIU(%d) must be between %d and %d, or LLCP link is not activated",
464 miu, LLCP_DEFAULT_MIU, nfa_p2p_cb.local_link_miu);
465 }
466 else if ((p_msg = (tNFA_P2P_API_CONNECT *) GKI_getbuf (sizeof (tNFA_P2P_API_CONNECT))) != NULL)
467 {
468 p_msg->hdr.event = NFA_P2P_API_CONNECT_EVT;
469
470 p_msg->service_name[LLCP_MAX_SN_LEN] = 0;
471
472 p_msg->dsap = dsap;
473 p_msg->miu = miu;
474 p_msg->rw = rw;
475 p_msg->client_handle = client_handle;
476
477 nfa_sys_sendmsg (p_msg);
478
479 return (NFA_STATUS_OK);
480 }
481
482 return (NFA_STATUS_FAILED);
483 }
484
485 /*******************************************************************************
486 **
487 ** Function NFA_P2pSendUI
488 **
489 ** Description This function is called to send data on connectionless
490 ** transport.
491 **
492 ** Returns NFA_STATUS_OK if successfully initiated
493 ** NFA_STATUS_BAD_HANDLE if handle is not valid
494 ** NFA_STATUS_BAD_LENGTH if data length is more than remote link MIU
495 ** NFA_STATUS_CONGESTED if congested
496 ** NFA_STATUS_FAILED otherwise
497 **
498 *******************************************************************************/
NFA_P2pSendUI(tNFA_HANDLE handle,UINT8 dsap,UINT16 length,UINT8 * p_data)499 tNFA_STATUS NFA_P2pSendUI (tNFA_HANDLE handle,
500 UINT8 dsap,
501 UINT16 length,
502 UINT8 *p_data)
503 {
504 tNFA_P2P_API_SEND_UI *p_msg;
505 tNFA_STATUS ret_status = NFA_STATUS_FAILED;
506 tNFA_HANDLE xx;
507
508 P2P_TRACE_API3 ("NFA_P2pSendUI (): handle:0x%X, DSAP:0x%02X, length:%d", handle, dsap, length);
509
510 GKI_sched_lock ();
511
512 xx = handle & NFA_HANDLE_MASK;
513
514 if ( (xx >= NFA_P2P_NUM_SAP)
515 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL))
516 {
517 P2P_TRACE_ERROR1 ("NFA_P2pSendUI (): Handle (0x%X) is not valid", handle);
518 ret_status = NFA_STATUS_BAD_HANDLE;
519 }
520 else if (length > nfa_p2p_cb.remote_link_miu)
521 {
522 P2P_TRACE_ERROR3 ("NFA_P2pSendUI (): handle:0x%X, length(%d) must be less than remote link MIU(%d)",
523 handle, length, nfa_p2p_cb.remote_link_miu);
524 ret_status = NFA_STATUS_BAD_LENGTH;
525 }
526 else if (nfa_p2p_cb.sap_cb[xx].flags & NFA_P2P_SAP_FLAG_LLINK_CONGESTED)
527 {
528 P2P_TRACE_WARNING1 ("NFA_P2pSendUI (): handle:0x%X, logical data link is already congested",
529 handle);
530 ret_status = NFA_STATUS_CONGESTED;
531 }
532 else if (LLCP_IsLogicalLinkCongested ((UINT8)xx,
533 nfa_p2p_cb.sap_cb[xx].num_pending_ui_pdu,
534 nfa_p2p_cb.total_pending_ui_pdu,
535 nfa_p2p_cb.total_pending_i_pdu))
536 {
537 nfa_p2p_cb.sap_cb[xx].flags |= NFA_P2P_SAP_FLAG_LLINK_CONGESTED;
538
539 P2P_TRACE_WARNING1 ("NFA_P2pSendUI(): handle:0x%X, logical data link is congested",
540 handle);
541 ret_status = NFA_STATUS_CONGESTED;
542 }
543 else if ((p_msg = (tNFA_P2P_API_SEND_UI *) GKI_getbuf (sizeof(tNFA_P2P_API_SEND_UI))) != NULL)
544 {
545 p_msg->hdr.event = NFA_P2P_API_SEND_UI_EVT;
546
547 p_msg->handle = handle;
548 p_msg->dsap = dsap;
549
550 if ((p_msg->p_msg = (BT_HDR *) GKI_getpoolbuf (LLCP_POOL_ID)) != NULL)
551 {
552 p_msg->p_msg->len = length;
553 p_msg->p_msg->offset = LLCP_MIN_OFFSET;
554 memcpy (((UINT8*) (p_msg->p_msg + 1) + p_msg->p_msg->offset), p_data, length);
555
556 /* increase number of tx UI PDU which is not processed by NFA for congestion control */
557 nfa_p2p_cb.sap_cb[xx].num_pending_ui_pdu++;
558 nfa_p2p_cb.total_pending_ui_pdu++;
559 nfa_sys_sendmsg (p_msg);
560
561 ret_status = NFA_STATUS_OK;
562 }
563 else
564 {
565 GKI_freebuf (p_msg);
566
567 nfa_p2p_cb.sap_cb[xx].flags |= NFA_P2P_SAP_FLAG_LLINK_CONGESTED;
568 ret_status = NFA_STATUS_CONGESTED;
569 }
570 }
571
572 GKI_sched_unlock ();
573
574 return (ret_status);
575 }
576
577 /*******************************************************************************
578 **
579 ** Function NFA_P2pReadUI
580 **
581 ** Description This function is called to read data on connectionless
582 ** transport when receiving NFA_P2P_DATA_EVT with NFA_P2P_LLINK_TYPE.
583 **
584 ** - Remote SAP who sent UI PDU is returned.
585 ** - Information of UI PDU up to max_data_len is copied into p_data.
586 ** - If more information of UI PDU or more UI PDU in queue then more
587 ** is returned to TRUE.
588 ** - Information of next UI PDU is not concatenated.
589 **
590 ** Returns NFA_STATUS_OK if successfully initiated
591 ** NFA_STATUS_BAD_HANDLE if handle is not valid
592 **
593 *******************************************************************************/
NFA_P2pReadUI(tNFA_HANDLE handle,UINT32 max_data_len,UINT8 * p_remote_sap,UINT32 * p_data_len,UINT8 * p_data,BOOLEAN * p_more)594 tNFA_STATUS NFA_P2pReadUI (tNFA_HANDLE handle,
595 UINT32 max_data_len,
596 UINT8 *p_remote_sap,
597 UINT32 *p_data_len,
598 UINT8 *p_data,
599 BOOLEAN *p_more)
600 {
601 tNFA_STATUS ret_status;
602 tNFA_HANDLE xx;
603
604 P2P_TRACE_API1 ("NFA_P2pReadUI (): handle:0x%X", handle);
605
606 GKI_sched_lock ();
607
608 xx = handle & NFA_HANDLE_MASK;
609
610 if ( (xx >= NFA_P2P_NUM_SAP)
611 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
612 {
613 P2P_TRACE_ERROR1 ("NFA_P2pReadUI (): Handle (0x%X) is not valid", handle);
614 ret_status = NFA_STATUS_BAD_HANDLE;
615 }
616 else
617 {
618 *p_more = LLCP_ReadLogicalLinkData ((UINT8)xx,
619 max_data_len,
620 p_remote_sap,
621 p_data_len,
622 p_data);
623 ret_status = NFA_STATUS_OK;
624 }
625
626 GKI_sched_unlock ();
627
628 return (ret_status);
629 }
630
631 /*******************************************************************************
632 **
633 ** Function NFA_P2pFlushUI
634 **
635 ** Description This function is called to flush data on connectionless
636 ** transport.
637 **
638 ** Returns NFA_STATUS_OK if successfully initiated
639 ** NFA_STATUS_BAD_HANDLE if handle is not valid
640 **
641 *******************************************************************************/
NFA_P2pFlushUI(tNFA_HANDLE handle,UINT32 * p_length)642 tNFA_STATUS NFA_P2pFlushUI (tNFA_HANDLE handle,
643 UINT32 *p_length)
644 {
645 tNFA_STATUS ret_status;
646 tNFA_HANDLE xx;
647
648 P2P_TRACE_API1 ("NFA_P2pReadUI (): handle:0x%X", handle);
649
650 GKI_sched_lock ();
651
652 xx = handle & NFA_HANDLE_MASK;
653
654 if ( (xx >= NFA_P2P_NUM_SAP)
655 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
656 {
657 P2P_TRACE_ERROR1 ("NFA_P2pFlushUI (): Handle (0x%X) is not valid", handle);
658 ret_status = NFA_STATUS_BAD_HANDLE;
659 *p_length = 0;
660 }
661 else
662 {
663 *p_length = LLCP_FlushLogicalLinkRxData ((UINT8)xx);
664 ret_status = NFA_STATUS_OK;
665 }
666
667 GKI_sched_unlock ();
668
669 return (ret_status);
670 }
671
672 /*******************************************************************************
673 **
674 ** Function NFA_P2pSendData
675 **
676 ** Description This function is called to send data on connection-oriented
677 ** transport.
678 **
679 ** Returns NFA_STATUS_OK if successfully initiated
680 ** NFA_STATUS_BAD_HANDLE if handle is not valid
681 ** NFA_STATUS_BAD_LENGTH if data length is more than remote MIU
682 ** NFA_STATUS_CONGESTED if congested
683 ** NFA_STATUS_FAILED otherwise
684 **
685 *******************************************************************************/
NFA_P2pSendData(tNFA_HANDLE handle,UINT16 length,UINT8 * p_data)686 tNFA_STATUS NFA_P2pSendData (tNFA_HANDLE handle,
687 UINT16 length,
688 UINT8 *p_data)
689 {
690 tNFA_P2P_API_SEND_DATA *p_msg;
691 tNFA_STATUS ret_status = NFA_STATUS_FAILED;
692 tNFA_HANDLE xx;
693
694 P2P_TRACE_API2 ("NFA_P2pSendData (): handle:0x%X, length:%d", handle, length);
695
696 GKI_sched_lock ();
697
698 xx = handle & NFA_HANDLE_MASK;
699 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
700
701 if ( (!(handle & NFA_P2P_HANDLE_FLAG_CONN))
702 ||(xx >= LLCP_MAX_DATA_LINK)
703 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
704 {
705 P2P_TRACE_ERROR1 ("NFA_P2pSendData (): Handle(0x%X) is not valid", handle);
706 ret_status = NFA_STATUS_BAD_HANDLE;
707 }
708 else if (nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO)
709 {
710 P2P_TRACE_ERROR1 ("NFA_P2pSendData (): handle:0x%X, Remote set RW to 0 (flow off)", handle);
711 ret_status = NFA_STATUS_FAILED;
712 }
713 else if (nfa_p2p_cb.conn_cb[xx].remote_miu < length)
714 {
715 P2P_TRACE_ERROR2 ("NFA_P2pSendData (): handle:0x%X, Data more than remote MIU(%d)",
716 handle, nfa_p2p_cb.conn_cb[xx].remote_miu);
717 ret_status = NFA_STATUS_BAD_LENGTH;
718 }
719 else if (nfa_p2p_cb.conn_cb[xx].flags & NFA_P2P_CONN_FLAG_CONGESTED)
720 {
721 P2P_TRACE_WARNING1 ("NFA_P2pSendData (): handle:0x%X, data link connection is already congested",
722 handle);
723 ret_status = NFA_STATUS_CONGESTED;
724 }
725 else if (LLCP_IsDataLinkCongested (nfa_p2p_cb.conn_cb[xx].local_sap,
726 nfa_p2p_cb.conn_cb[xx].remote_sap,
727 nfa_p2p_cb.conn_cb[xx].num_pending_i_pdu,
728 nfa_p2p_cb.total_pending_ui_pdu,
729 nfa_p2p_cb.total_pending_i_pdu))
730 {
731 nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_CONGESTED;
732
733 P2P_TRACE_WARNING1 ("NFA_P2pSendData (): handle:0x%X, data link connection is congested",
734 handle);
735 ret_status = NFA_STATUS_CONGESTED;
736 }
737 else if ((p_msg = (tNFA_P2P_API_SEND_DATA *) GKI_getbuf (sizeof(tNFA_P2P_API_SEND_DATA))) != NULL)
738 {
739 p_msg->hdr.event = NFA_P2P_API_SEND_DATA_EVT;
740
741 p_msg->conn_handle = handle;
742
743 if ((p_msg->p_msg = (BT_HDR *) GKI_getpoolbuf (LLCP_POOL_ID)) != NULL)
744 {
745 p_msg->p_msg->len = length;
746 p_msg->p_msg->offset = LLCP_MIN_OFFSET;
747 memcpy (((UINT8*) (p_msg->p_msg + 1) + p_msg->p_msg->offset), p_data, length);
748
749 /* increase number of tx I PDU which is not processed by NFA for congestion control */
750 nfa_p2p_cb.conn_cb[xx].num_pending_i_pdu++;
751 nfa_p2p_cb.total_pending_i_pdu++;
752 nfa_sys_sendmsg (p_msg);
753
754 ret_status = NFA_STATUS_OK;
755 }
756 else
757 {
758 GKI_freebuf (p_msg);
759 nfa_p2p_cb.conn_cb[xx].flags |= NFA_P2P_CONN_FLAG_CONGESTED;
760 ret_status = NFA_STATUS_CONGESTED;
761 }
762 }
763
764 GKI_sched_unlock ();
765
766 return (ret_status);
767 }
768
769 /*******************************************************************************
770 **
771 ** Function NFA_P2pReadData
772 **
773 ** Description This function is called to read data on connection-oriented
774 ** transport when receiving NFA_P2P_DATA_EVT with NFA_P2P_DLINK_TYPE.
775 **
776 ** - Information of I PDU is copied into p_data up to max_data_len.
777 ** - If more information of I PDU or more I PDU in queue, then more
778 ** is returned to TRUE.
779 ** - Information of next I PDU is not concatenated.
780 **
781 ** Returns NFA_STATUS_OK if successfully initiated
782 ** NFA_STATUS_BAD_HANDLE if handle is not valid
783 **
784 *******************************************************************************/
NFA_P2pReadData(tNFA_HANDLE handle,UINT32 max_data_len,UINT32 * p_data_len,UINT8 * p_data,BOOLEAN * p_more)785 tNFA_STATUS NFA_P2pReadData (tNFA_HANDLE handle,
786 UINT32 max_data_len,
787 UINT32 *p_data_len,
788 UINT8 *p_data,
789 BOOLEAN *p_more)
790 {
791 tNFA_STATUS ret_status;
792 tNFA_HANDLE xx;
793
794 P2P_TRACE_API1 ("NFA_P2pReadData (): handle:0x%X", handle);
795
796 GKI_sched_lock ();
797
798 xx = handle & NFA_HANDLE_MASK;
799 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
800
801 if ( (!(handle & NFA_P2P_HANDLE_FLAG_CONN))
802 ||(xx >= LLCP_MAX_DATA_LINK)
803 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
804 {
805 P2P_TRACE_ERROR1 ("NFA_P2pReadData (): Handle(0x%X) is not valid", handle);
806 ret_status = NFA_STATUS_BAD_HANDLE;
807 }
808 else
809 {
810 *p_more = LLCP_ReadDataLinkData (nfa_p2p_cb.conn_cb[xx].local_sap,
811 nfa_p2p_cb.conn_cb[xx].remote_sap,
812 max_data_len,
813 p_data_len,
814 p_data);
815 ret_status = NFA_STATUS_OK;
816 }
817
818 GKI_sched_unlock ();
819
820 return (ret_status);
821 }
822
823 /*******************************************************************************
824 **
825 ** Function NFA_P2pFlushData
826 **
827 ** Description This function is called to flush data on connection-oriented
828 ** transport.
829 **
830 ** Returns NFA_STATUS_OK if successfully initiated
831 ** NFA_STATUS_BAD_HANDLE if handle is not valid
832 **
833 *******************************************************************************/
NFA_P2pFlushData(tNFA_HANDLE handle,UINT32 * p_length)834 tNFA_STATUS NFA_P2pFlushData (tNFA_HANDLE handle,
835 UINT32 *p_length)
836 {
837 tNFA_STATUS ret_status;
838 tNFA_HANDLE xx;
839
840 P2P_TRACE_API1 ("NFA_P2pFlushData (): handle:0x%X", handle);
841
842 GKI_sched_lock ();
843
844 xx = handle & NFA_HANDLE_MASK;
845 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
846
847 if ( (!(handle & NFA_P2P_HANDLE_FLAG_CONN))
848 ||(xx >= LLCP_MAX_DATA_LINK)
849 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
850 {
851 P2P_TRACE_ERROR1 ("NFA_P2pFlushData (): Handle(0x%X) is not valid", handle);
852 ret_status = NFA_STATUS_BAD_HANDLE;
853 }
854 else
855 {
856 *p_length = LLCP_FlushDataLinkRxData (nfa_p2p_cb.conn_cb[xx].local_sap,
857 nfa_p2p_cb.conn_cb[xx].remote_sap);
858 ret_status = NFA_STATUS_OK;
859 }
860
861 GKI_sched_unlock ();
862
863 return (ret_status);
864 }
865
866 /*******************************************************************************
867 **
868 ** Function NFA_P2pSetLocalBusy
869 **
870 ** Description This function is called to stop or resume incoming data on
871 ** connection-oriented transport.
872 **
873 ** Returns NFA_STATUS_OK if successfully initiated
874 ** NFA_STATUS_BAD_HANDLE if handle is not valid
875 ** NFA_STATUS_FAILED otherwise
876 **
877 *******************************************************************************/
NFA_P2pSetLocalBusy(tNFA_HANDLE conn_handle,BOOLEAN is_busy)878 tNFA_STATUS NFA_P2pSetLocalBusy (tNFA_HANDLE conn_handle,
879 BOOLEAN is_busy)
880 {
881 tNFA_P2P_API_SET_LOCAL_BUSY *p_msg;
882 tNFA_HANDLE xx;
883
884 P2P_TRACE_API2 ("NFA_P2pSetLocalBusy (): conn_handle:0x%02X, is_busy:%d", conn_handle, is_busy);
885
886 xx = conn_handle & NFA_HANDLE_MASK;
887
888 if (!(xx & NFA_P2P_HANDLE_FLAG_CONN))
889 {
890 P2P_TRACE_ERROR0 ("NFA_P2pSetLocalBusy (): Connection Handle is not valid");
891 return (NFA_STATUS_BAD_HANDLE);
892 }
893 else
894 {
895 xx &= ~NFA_P2P_HANDLE_FLAG_CONN;
896 }
897
898 if ( (xx >= LLCP_MAX_DATA_LINK)
899 ||(nfa_p2p_cb.conn_cb[xx].flags == 0) )
900 {
901 P2P_TRACE_ERROR0 ("NFA_P2pSetLocalBusy (): Connection Handle is not valid");
902 return (NFA_STATUS_BAD_HANDLE);
903 }
904
905 if ((p_msg = (tNFA_P2P_API_SET_LOCAL_BUSY *) GKI_getbuf (sizeof (tNFA_P2P_API_SET_LOCAL_BUSY))) != NULL)
906 {
907 p_msg->hdr.event = NFA_P2P_API_SET_LOCAL_BUSY_EVT;
908
909 p_msg->conn_handle = conn_handle;
910 p_msg->is_busy = is_busy;
911
912 nfa_sys_sendmsg (p_msg);
913
914 return (NFA_STATUS_OK);
915 }
916
917 return (NFA_STATUS_FAILED);
918 }
919
920 /*******************************************************************************
921 **
922 ** Function NFA_P2pGetLinkInfo
923 **
924 ** Description This function is called to get local/remote link MIU and
925 ** Well-Known Service list encoded as a 16-bit field of connected LLCP.
926 ** NFA_P2P_LINK_INFO_EVT will be returned.
927 **
928 ** Returns NFA_STATUS_OK if successfully initiated
929 ** NFA_STATUS_BAD_HANDLE if server or client is not registered
930 ** NFA_STATUS_FAILED otherwise
931 **
932 *******************************************************************************/
NFA_P2pGetLinkInfo(tNFA_HANDLE handle)933 tNFA_STATUS NFA_P2pGetLinkInfo (tNFA_HANDLE handle)
934 {
935 tNFA_P2P_API_GET_LINK_INFO *p_msg;
936 tNFA_HANDLE xx;
937
938 P2P_TRACE_API1 ("NFA_P2pGetLinkInfo (): handle:0x%x", handle);
939
940 if (nfa_p2p_cb.llcp_state != NFA_P2P_LLCP_STATE_ACTIVATED)
941 {
942 P2P_TRACE_ERROR0 ("NFA_P2pGetLinkInfo (): LLCP link is not activated");
943 return (NFA_STATUS_FAILED);
944 }
945
946 xx = handle & NFA_HANDLE_MASK;
947
948 if ( (xx >= NFA_P2P_NUM_SAP)
949 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
950 {
951 P2P_TRACE_ERROR0 ("NFA_P2pGetLinkInfo (): Handle is invalid or not registered");
952 return (NFA_STATUS_BAD_HANDLE);
953 }
954
955 if ((p_msg = (tNFA_P2P_API_GET_LINK_INFO *) GKI_getbuf (sizeof (tNFA_P2P_API_GET_LINK_INFO))) != NULL)
956 {
957 p_msg->hdr.event = NFA_P2P_API_GET_LINK_INFO_EVT;
958
959 p_msg->handle = handle;
960
961 nfa_sys_sendmsg (p_msg);
962
963 return (NFA_STATUS_OK);
964 }
965
966 return (NFA_STATUS_FAILED);
967 }
968
969 /*******************************************************************************
970 **
971 ** Function NFA_P2pGetRemoteSap
972 **
973 ** Description This function is called to get SAP associated by service name
974 ** on connected remote LLCP.
975 ** NFA_P2P_SDP_EVT will be returned.
976 **
977 ** Returns NFA_STATUS_OK if successfully initiated
978 ** NFA_STATUS_BAD_HANDLE if server or client is not registered
979 ** NFA_STATUS_FAILED otherwise
980 **
981 *******************************************************************************/
NFA_P2pGetRemoteSap(tNFA_HANDLE handle,char * p_service_name)982 tNFA_STATUS NFA_P2pGetRemoteSap (tNFA_HANDLE handle,
983 char *p_service_name)
984 {
985 tNFA_P2P_API_GET_REMOTE_SAP *p_msg;
986 tNFA_HANDLE xx;
987
988 P2P_TRACE_API2 ("NFA_P2pGetRemoteSap(): handle:0x%x, SN:<%s>", handle, p_service_name);
989
990 if (nfa_p2p_cb.llcp_state != NFA_P2P_LLCP_STATE_ACTIVATED)
991 {
992 P2P_TRACE_ERROR0 ("NFA_P2pGetRemoteSap(): LLCP link is not activated");
993 return (NFA_STATUS_FAILED);
994 }
995
996 xx = handle & NFA_HANDLE_MASK;
997
998 if ( (xx >= NFA_P2P_NUM_SAP)
999 ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) )
1000 {
1001 P2P_TRACE_ERROR0 ("NFA_P2pGetRemoteSap (): Handle is invalid or not registered");
1002 return (NFA_STATUS_BAD_HANDLE);
1003 }
1004
1005 if ((p_msg = (tNFA_P2P_API_GET_REMOTE_SAP *) GKI_getbuf (sizeof (tNFA_P2P_API_GET_REMOTE_SAP))) != NULL)
1006 {
1007 p_msg->hdr.event = NFA_P2P_API_GET_REMOTE_SAP_EVT;
1008
1009 p_msg->handle = handle;
1010
1011 BCM_STRNCPY_S (p_msg->service_name, sizeof (p_msg->service_name), p_service_name, LLCP_MAX_SN_LEN);
1012 p_msg->service_name[LLCP_MAX_SN_LEN] = 0;
1013
1014 nfa_sys_sendmsg (p_msg);
1015
1016 return (NFA_STATUS_OK);
1017 }
1018
1019 return (NFA_STATUS_FAILED);
1020 }
1021
1022 /*******************************************************************************
1023 **
1024 ** Function NFA_P2pSetLLCPConfig
1025 **
1026 ** Description This function is called to change LLCP config parameters.
1027 ** Application must call while LLCP is not activated.
1028 **
1029 ** Parameters descriptions (default value)
1030 ** - Local Link MIU (LLCP_MIU)
1031 ** - Option parameter (LLCP_OPT_VALUE)
1032 ** - Response Waiting Time Index (LLCP_WAITING_TIME)
1033 ** - Local Link Timeout (LLCP_LTO_VALUE)
1034 ** - Inactivity Timeout as initiator role (LLCP_INIT_INACTIVITY_TIMEOUT)
1035 ** - Inactivity Timeout as target role (LLCP_TARGET_INACTIVITY_TIMEOUT)
1036 ** - Delay SYMM response (LLCP_DELAY_RESP_TIME)
1037 ** - Data link connection timeout (LLCP_DATA_LINK_CONNECTION_TOUT)
1038 ** - Delay timeout to send first PDU as initiator (LLCP_DELAY_TIME_TO_SEND_FIRST_PDU)
1039 **
1040 ** Returns NFA_STATUS_OK if successfully initiated
1041 ** NFA_STATUS_FAILED otherwise
1042 **
1043 *******************************************************************************/
NFA_P2pSetLLCPConfig(UINT16 link_miu,UINT8 opt,UINT8 wt,UINT16 link_timeout,UINT16 inact_timeout_init,UINT16 inact_timeout_target,UINT16 symm_delay,UINT16 data_link_timeout,UINT16 delay_first_pdu_timeout)1044 tNFA_STATUS NFA_P2pSetLLCPConfig (UINT16 link_miu,
1045 UINT8 opt,
1046 UINT8 wt,
1047 UINT16 link_timeout,
1048 UINT16 inact_timeout_init,
1049 UINT16 inact_timeout_target,
1050 UINT16 symm_delay,
1051 UINT16 data_link_timeout,
1052 UINT16 delay_first_pdu_timeout)
1053 {
1054 tNFA_P2P_API_SET_LLCP_CFG *p_msg;
1055
1056 P2P_TRACE_API4 ("NFA_P2pSetLLCPConfig ():link_miu:%d, opt:0x%02X, wt:%d, link_timeout:%d",
1057 link_miu, opt, wt, link_timeout);
1058 P2P_TRACE_API4 (" inact_timeout(init:%d, target:%d), symm_delay:%d, data_link_timeout:%d",
1059 inact_timeout_init, inact_timeout_target, symm_delay, data_link_timeout);
1060 P2P_TRACE_API1 (" delay_first_pdu_timeout:%d", delay_first_pdu_timeout);
1061
1062 if (nfa_p2p_cb.llcp_state == NFA_P2P_LLCP_STATE_ACTIVATED)
1063 {
1064 P2P_TRACE_ERROR0 ("NFA_P2pSetLLCPConfig (): LLCP link is activated");
1065 return (NFA_STATUS_FAILED);
1066 }
1067
1068 if ((p_msg = (tNFA_P2P_API_SET_LLCP_CFG *) GKI_getbuf (sizeof (tNFA_P2P_API_SET_LLCP_CFG))) != NULL)
1069 {
1070 p_msg->hdr.event = NFA_P2P_API_SET_LLCP_CFG_EVT;
1071
1072 p_msg->link_miu = link_miu;
1073 p_msg->opt = opt;
1074 p_msg->wt = wt;
1075 p_msg->link_timeout = link_timeout;
1076 p_msg->inact_timeout_init = inact_timeout_init;
1077 p_msg->inact_timeout_target = inact_timeout_target;
1078 p_msg->symm_delay = symm_delay;
1079 p_msg->data_link_timeout = data_link_timeout;
1080 p_msg->delay_first_pdu_timeout = delay_first_pdu_timeout;
1081
1082 nfa_sys_sendmsg (p_msg);
1083
1084 return (NFA_STATUS_OK);
1085 }
1086
1087 return (NFA_STATUS_FAILED);
1088 }
1089
1090 /*******************************************************************************
1091 **
1092 ** Function NFA_P2pGetLLCPConfig
1093 **
1094 ** Description This function is called to read LLCP config parameters.
1095 **
1096 ** Parameters descriptions
1097 ** - Local Link MIU
1098 ** - Option parameter
1099 ** - Response Waiting Time Index
1100 ** - Local Link Timeout
1101 ** - Inactivity Timeout as initiator role
1102 ** - Inactivity Timeout as target role
1103 ** - Delay SYMM response
1104 ** - Data link connection timeout
1105 ** - Delay timeout to send first PDU as initiator
1106 **
1107 ** Returns None
1108 **
1109 *******************************************************************************/
NFA_P2pGetLLCPConfig(UINT16 * p_link_miu,UINT8 * p_opt,UINT8 * p_wt,UINT16 * p_link_timeout,UINT16 * p_inact_timeout_init,UINT16 * p_inact_timeout_target,UINT16 * p_symm_delay,UINT16 * p_data_link_timeout,UINT16 * p_delay_first_pdu_timeout)1110 void NFA_P2pGetLLCPConfig (UINT16 *p_link_miu,
1111 UINT8 *p_opt,
1112 UINT8 *p_wt,
1113 UINT16 *p_link_timeout,
1114 UINT16 *p_inact_timeout_init,
1115 UINT16 *p_inact_timeout_target,
1116 UINT16 *p_symm_delay,
1117 UINT16 *p_data_link_timeout,
1118 UINT16 *p_delay_first_pdu_timeout)
1119 {
1120 LLCP_GetConfig (p_link_miu,
1121 p_opt,
1122 p_wt,
1123 p_link_timeout,
1124 p_inact_timeout_init,
1125 p_inact_timeout_target,
1126 p_symm_delay,
1127 p_data_link_timeout,
1128 p_delay_first_pdu_timeout);
1129
1130 P2P_TRACE_API4 ("NFA_P2pGetLLCPConfig () link_miu:%d, opt:0x%02X, wt:%d, link_timeout:%d",
1131 *p_link_miu, *p_opt, *p_wt, *p_link_timeout);
1132 P2P_TRACE_API4 (" inact_timeout(init:%d, target:%d), symm_delay:%d, data_link_timeout:%d",
1133 *p_inact_timeout_init, *p_inact_timeout_target, *p_symm_delay, *p_data_link_timeout);
1134 P2P_TRACE_API1 (" delay_first_pdu_timeout:%d", *p_delay_first_pdu_timeout);
1135
1136 }
1137
1138 /*******************************************************************************
1139 **
1140 ** Function NFA_P2pSetTraceLevel
1141 **
1142 ** Description This function sets the trace level for P2P. If called with
1143 ** a value of 0xFF, it simply returns the current trace level.
1144 **
1145 ** Returns The new or current trace level
1146 **
1147 *******************************************************************************/
NFA_P2pSetTraceLevel(UINT8 new_level)1148 UINT8 NFA_P2pSetTraceLevel (UINT8 new_level)
1149 {
1150 if (new_level != 0xFF)
1151 nfa_p2p_cb.trace_level = new_level;
1152
1153 return (nfa_p2p_cb.trace_level);
1154 }
1155
1156