diff options
author | Sylvain Fonteneau <sylvain.fonteneau@trusted-logic.com> | 2011-01-14 14:40:51 +0100 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2011-01-18 15:30:34 -0800 |
commit | 8608ad938da280b895e3bb71435d6fe34c589219 (patch) | |
tree | f22d984c16bb723bdec939c69038217150dbaaad /src | |
parent | a3af9c908f5c50e2405169015c86a1b667b42490 (diff) | |
download | external_libnfc-nxp-8608ad938da280b895e3bb71435d6fe34c589219.zip external_libnfc-nxp-8608ad938da280b895e3bb71435d6fe34c589219.tar.gz external_libnfc-nxp-8608ad938da280b895e3bb71435d6fe34c589219.tar.bz2 |
Fixed LLCP receive window checkings.
Before sending a packet, the LLCP stack have to check if the remote
peer is ready to send. To do so, a Receive Window mechanism based on
packet numbering and acknowledgment is used.
Basically, the sender have to make sure that he must have not sent
more than RW-1 unaknowledged frames before sending a new one. This
patch is correcting this test which was failing in some situations.
Change-Id: I525f6b472a909ce48feb938aa02858b9456edc11
Diffstat (limited to 'src')
-rw-r--r-- | src/phFriNfc_Llcp.h | 3 | ||||
-rw-r--r-- | src/phFriNfc_LlcpTransport_Connection.c | 12 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/phFriNfc_Llcp.h b/src/phFriNfc_Llcp.h index ce68907..4d2e71e 100644 --- a/src/phFriNfc_Llcp.h +++ b/src/phFriNfc_Llcp.h @@ -187,6 +187,9 @@ extern char phOsalNfc_DbgTraceBuffer[]; PHFRINFC_LLCP_TLV_MIUX_MASK) /**< Maximum size of a packet */ /*@}*/ +/*========== MACROS ===========*/ + +#define CHECK_SEND_RW(socket) ( (((socket)->socket_VS - (socket)->socket_VSA) % 16) < (socket)->remoteRW ) /*========== ENUMERATES ===========*/ diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c index 1f670cd..93dde68 100644 --- a/src/phFriNfc_LlcpTransport_Connection.c +++ b/src/phFriNfc_LlcpTransport_Connection.c @@ -181,7 +181,7 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p if(psLocalLlcpSocket->bSocketSendPending == TRUE) { /* Test the RW window */ - if(psLocalLlcpSocket->socket_VS != (psLocalLlcpSocket->socket_VSA + psLocalLlcpSocket->remoteRW)) + if(CHECK_SEND_RW(psLocalLlcpSocket)) { /* Set the Header */ psLocalLlcpSocket->sLlcpHeader.dsap = psLocalLlcpSocket->socket_dSap; @@ -1265,7 +1265,7 @@ static void Handle_Receive_IFrame(phFriNfc_LlcpTransport_t *psTransport, psLocalLlcpSocket->pfSocketRecv_Cb = NULL; /* Test if a send is pending with this socket */ - if(psLocalLlcpSocket->bSocketSendPending == TRUE && (psLocalLlcpSocket->socket_VS != (psLocalLlcpSocket->socket_VSA + psLocalLlcpSocket->remoteRW))) + if(psLocalLlcpSocket->bSocketSendPending == TRUE && CHECK_SEND_RW(psLocalLlcpSocket)) { /* Test if a send is pending at LLC layer */ if(psTransport->bSendPending != TRUE) @@ -1371,7 +1371,7 @@ static void Handle_Receive_IFrame(phFriNfc_LlcpTransport_t *psTransport, } /* Test if a send is pending with this socket */ - if((psLocalLlcpSocket->bSocketSendPending == TRUE) && (psLocalLlcpSocket->socket_VS != (psLocalLlcpSocket->socket_VSA + psLocalLlcpSocket->remoteRW))) + if((psLocalLlcpSocket->bSocketSendPending == TRUE) && CHECK_SEND_RW(psLocalLlcpSocket)) { /* Test if a send is pending at LLC layer */ if(psTransport->bSendPending != TRUE) @@ -1533,7 +1533,7 @@ static void Handle_ReceiveReady_Frame(phFriNfc_LlcpTransport_t *psTransport if(psLocalLlcpSocket->bSocketSendPending == TRUE) { /* Test the RW window */ - if(psLocalLlcpSocket->socket_VS != (psLocalLlcpSocket->socket_VSA + psLocalLlcpSocket->remoteRW)) + if(CHECK_SEND_RW(psLocalLlcpSocket)) { /* Test if a send is pending at LLC layer */ if(psTransport->bSendPending != TRUE) @@ -1669,7 +1669,7 @@ static void Handle_ReceiveNotReady_Frame(phFriNfc_LlcpTransport_t *psTransp psLocalLlcpSocket->socket_VSA = (uint8_t)sLlcpLocalSequence.nr; /* Test if a send is pendind */ - if(psLocalLlcpSocket->bSocketSendPending == TRUE && (psLocalLlcpSocket->socket_VS != (psLocalLlcpSocket->socket_VSA + psLocalLlcpSocket->remoteRW))) + if(psLocalLlcpSocket->bSocketSendPending == TRUE && CHECK_SEND_RW(psLocalLlcpSocket)) { /* Test if a send is pending at LLC layer */ if(psTransport->bSendPending != TRUE) @@ -2567,7 +2567,7 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Send(phFriNfc_LlcpTransport_ /* Test the RW window */ - if(pLlcpSocket->socket_VS == (pLlcpSocket->socket_VSA + pLlcpSocket->remoteRW)) + if(!CHECK_SEND_RW(pLlcpSocket)) { /* Store the Send CB and context */ pLlcpSocket->pfSocketSend_Cb = pSend_RspCb; |