diff options
author | Martijn Coenen <maco@google.com> | 2013-03-06 13:31:30 -0800 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2013-03-06 13:31:30 -0800 |
commit | 3cbab5882f6d89a52068a3fa72a7223971d6b7fd (patch) | |
tree | a70d30d3b9073519c7e91bcd747f67d02563c2b9 | |
parent | 837efc3194a03beaaa32b370c63a9270ed9664d8 (diff) | |
download | libnfc-nxp-3cbab5882f6d89a52068a3fa72a7223971d6b7fd.tar.gz |
Make sure LLCP header fields are reset.
In some conditions these would persist
over a link tear-down, causing them to
be sent out the next time the link comes up.
Also, don't overwrite them if a send is
still in progress.
Change-Id: I19dec5d79ae4b25f41fb5e8a0514e565ceca7a91
-rw-r--r-- | src/phFriNfc_Llcp.c | 11 | ||||
-rw-r--r-- | src/phFriNfc_LlcpTransport_Connection.c | 12 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/phFriNfc_Llcp.c b/src/phFriNfc_Llcp.c index ca2836a..5b9736b 100644 --- a/src/phFriNfc_Llcp.c +++ b/src/phFriNfc_Llcp.c @@ -162,13 +162,13 @@ static NFCSTATUS phFriNfc_Llcp_InternalDeactivate( phFriNfc_Llcp_t *Llcp ) /* Stop timer */ phOsalNfc_Timer_Stop(Llcp->hSymmTimer); + Llcp->psSendHeader = NULL; + Llcp->psSendSequence = NULL; /* Return delayed send operation in error, in any */ if (Llcp->psSendInfo != NULL) { phFriNfc_Llcp_Deallocate(Llcp->psSendInfo); Llcp->psSendInfo = NULL; - Llcp->psSendHeader = NULL; - Llcp->psSendSequence = NULL; } if (Llcp->pfSendCB != NULL) { @@ -560,7 +560,6 @@ static NFCSTATUS phFriNfc_Llcp_InternalActivate( phFriNfc_Llcp_t *Llcp, phFriNfc_Llcp_ResetLTO(Llcp); } } - /* Notify upper layer, if Activation failed CB called by Deactivate */ if (status == NFCSTATUS_SUCCESS) { @@ -869,7 +868,6 @@ static bool_t phFriNfc_Llcp_HandlePendingSend ( phFriNfc_Llcp_t *Llcp ) NFCSTATUS result; uint8_t bDeallocate = FALSE; uint8_t return_value = FALSE; - /* Handle pending disconnection request */ if (Llcp->bDiscPendingFlag == TRUE) { @@ -1339,6 +1337,10 @@ NFCSTATUS phFriNfc_Llcp_Activate( phFriNfc_Llcp_t *Llcp ) /* Update state */ Llcp->state = PHFRINFC_LLCP_STATE_ACTIVATION; + /* Reset any headers to send */ + Llcp->psSendHeader = NULL; + Llcp->psSendSequence = NULL; + /* Forward check request to MAC layer */ return phFriNfc_LlcpMac_Activate(&Llcp->MAC); } @@ -1413,7 +1415,6 @@ NFCSTATUS phFriNfc_Llcp_Send( phFriNfc_Llcp_t *Llcp, void *pContext ) { NFCSTATUS result; - /* Check parameters */ if ((Llcp == NULL) || (psHeader == NULL) || (pfSend_CB == NULL)) { diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c index 4f7badf..f4be919 100644 --- a/src/phFriNfc_LlcpTransport_Connection.c +++ b/src/phFriNfc_LlcpTransport_Connection.c @@ -52,7 +52,6 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p uint8_t index; uint8_t socketFound = FALSE; NFCSTATUS result; - /* Get Send CB context */ psTransport = (phFriNfc_LlcpTransport_t*)pContext; @@ -227,7 +226,6 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_HandlePendingOperations(phFr pSocket->pSocketErrCb(pSocket->pContext, PHFRINFC_LLCP_ERR_DISCONNECTED); } } - return result; } @@ -2053,11 +2051,6 @@ NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(phFriNfc_LlcpTran } } - /* Set the socket Header */ - pLlcpSocket->sLlcpHeader.dsap = pLlcpSocket->socket_dSap; - pLlcpSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_DISC; - pLlcpSocket->sLlcpHeader.ssap = pLlcpSocket->socket_sSap; - /* Test if a send is pending */ if( testAndSetSendPending(pLlcpSocket->psTransport)) { @@ -2066,6 +2059,11 @@ NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(phFriNfc_LlcpTran } else { + /* Set the socket Header */ + pLlcpSocket->sLlcpHeader.dsap = pLlcpSocket->socket_dSap; + pLlcpSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_DISC; + pLlcpSocket->sLlcpHeader.ssap = pLlcpSocket->socket_sSap; + status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport, &pLlcpSocket->sLlcpHeader, NULL, |