summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Ferir <arnaud.ferir@trusted-logic.com>2011-01-14 17:31:22 +0100
committerNick Pelly <npelly@google.com>2011-01-18 15:31:18 -0800
commit407d793f3038222dac95651866b99cd064e214eb (patch)
treefb4f9f8a5b7ed1cb49cd06295a3b3b8e115a94da
parent42fd1ffc1f8f87e7faca1724d128dafa70ff3b1e (diff)
downloadlibnfc-nxp-407d793f3038222dac95651866b99cd064e214eb.tar.gz
Fixed LLCP send callback triggering.
The phLibNfc_Llcp_Send() function is expected to trigger a callback when the packet is actually sent but, in some situations, the callback was triggered by another frame sending (such as RR or DM frames). This patch fixes the following socket internal flags handling: - pfSocketSend_Cb: set to non-NULL value when a send operation is pending, - bSocketSendPending: set to TRUE if the LLCP link layer is not available for sending and reset to FALSE once the frame is actually forwarded to the LLCP link layer. The send callback triggering has been updated to ensure it is only done for the expected data frame (i.e.: send pending and already forwarded to link layer). Change-Id: Id7410ee4075fbbbc9de382abf54e89a97f6a8b37
-rw-r--r--src/phFriNfc_LlcpTransport.c2
-rw-r--r--src/phFriNfc_LlcpTransport_Connection.c11
2 files changed, 5 insertions, 8 deletions
diff --git a/src/phFriNfc_LlcpTransport.c b/src/phFriNfc_LlcpTransport.c
index 07ace35..130564d 100644
--- a/src/phFriNfc_LlcpTransport.c
+++ b/src/phFriNfc_LlcpTransport.c
@@ -1045,7 +1045,7 @@ NFCSTATUS phFriNfc_LlcpTransport_Send(phFriNfc_LlcpTransport_Socket_t*
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER);
}
/* Test if a send is pending */
- else if(pLlcpSocket->bSocketSendPending == TRUE)
+ else if(pLlcpSocket->pfSocketSend_Cb != NULL)
{
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_REJECTED);
}
diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c
index 9746d5b..95b5527 100644
--- a/src/phFriNfc_LlcpTransport_Connection.c
+++ b/src/phFriNfc_LlcpTransport_Connection.c
@@ -125,7 +125,7 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p
case phFriNfc_LlcpTransportSocket_eSocketConnected:
{
- if(psTransport->pSocketTable[psTransport->socketIndex].sLlcpHeader.ptype == PHFRINFC_LLCP_PTYPE_I && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL)
+ if(!psTransport->pSocketTable[psTransport->socketIndex].bSocketSendPending && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL)
{
psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb(psTransport->pSocketTable[psTransport->socketIndex].pSendContext,status);
psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb = NULL;
@@ -310,13 +310,10 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p
psLocalLlcpSocket->pSocketErrCb(psLocalLlcpSocket->pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
}
/* Call SEND IFRAME CB */
- else if(psLocalLlcpSocket->pfSocketSend_Cb != NULL)
+ else if((psLocalLlcpSocket->pfSocketSend_Cb != NULL) && !psLocalLlcpSocket->bSocketSendPending)
{
psLocalLlcpSocket->pfSocketSend_Cb(psLocalLlcpSocket->pSendContext,status);
- if(psTransport->pSocketTable[psTransport->socketIndex].bSocketSendPending != TRUE)
- {
- psLocalLlcpSocket->pfSocketSend_Cb = NULL;
- }
+ psLocalLlcpSocket->pfSocketSend_Cb = NULL;
}
}
/* Reset the current length of the send buffer */
@@ -325,7 +322,7 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p
else
{
/* Send CB error */
- if(psTransport->pSocketTable[psTransport->socketIndex].sLlcpHeader.ptype == PHFRINFC_LLCP_PTYPE_I && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL)
+ if(!psTransport->pSocketTable[psTransport->socketIndex].bSocketSendPending && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL)
{
psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb(psTransport->pSocketTable[psTransport->socketIndex].pSendContext,status);
psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb = NULL;