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