summaryrefslogtreecommitdiffstats
path: root/src/phFriNfc_LlcpTransport_Connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/phFriNfc_LlcpTransport_Connection.c')
-rw-r--r--src/phFriNfc_LlcpTransport_Connection.c659
1 files changed, 215 insertions, 444 deletions
diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c
index b75406b..f58b33f 100644
--- a/src/phFriNfc_LlcpTransport_Connection.c
+++ b/src/phFriNfc_LlcpTransport_Connection.c
@@ -32,13 +32,7 @@
#include <phFriNfc_LlcpUtils.h>
/* Function definition */
-static NFCSTATUS phFriNfc_Llcp_Send_DisconnectMode_Frame(phFriNfc_LlcpTransport_t* psTransport,
- uint8_t dsap,
- uint8_t ssap,
- uint8_t dmOpCode);
-
static NFCSTATUS phFriNfc_Llcp_Send_ReceiveReady_Frame(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket);
-
static NFCSTATUS phFriNfc_Llcp_Send_ReceiveNotReady_Frame(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket);
static NFCSTATUS static_performSendInfo(phFriNfc_LlcpTransport_Socket_t * psLlcpSocket);
@@ -74,40 +68,8 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p
/* Get Send CB context */
psTransport = (phFriNfc_LlcpTransport_t*)pContext;
- /* Reset the FLAG send pending*/
- psTransport->bSendPending = FALSE;
-
if(status == NFCSTATUS_SUCCESS)
{
- if(psTransport->bFrmrPending)
- {
- /* Reset FRMR pending */
- psTransport->bFrmrPending = FALSE;
-
- /* Send Frmr */
- sFrmrBuffer.buffer = psTransport->FrmrInfoBuffer;
- sFrmrBuffer.length = 0x04; /* Size of FRMR Information field */
-
- result = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psTransport->sLlcpHeader,
- NULL,
- &sFrmrBuffer,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
- }
- else if(psTransport->bDmPending)
- {
- /* Reset DM pending */
- psTransport->bDmPending = FALSE;
-
- /* Send DM pending */
- result = phFriNfc_Llcp_Send_DisconnectMode_Frame(psTransport,
- psTransport->DmInfoBuffer[0],
- psTransport->DmInfoBuffer[1],
- psTransport->DmInfoBuffer[2]);
- }
-
-
/* Test the socket */
switch(psTransport->pSocketTable[psTransport->socketIndex].eSocket_State)
{
@@ -142,170 +104,125 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB(void* p
psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb = NULL;
}
}break;
- default: break;
+ default:
+ /* Nothing to do */
+ break;
}
-
- /* Update Index value with the next socket */
- index = psTransport->socketIndex+1;
-
- /* Search for a socket with a flag Pending */
- do
+ }
+ else
+ {
+ /* Send CB error */
+ if(!psTransport->pSocketTable[psTransport->socketIndex].bSocketSendPending && psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb != NULL)
{
- if(index >= PHFRINFC_LLCP_NB_SOCKET_MAX)
- {
- index = 0;
- }
+ psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb(psTransport->pSocketTable[psTransport->socketIndex].pSendContext,status);
+ psTransport->pSocketTable[psTransport->socketIndex].pfSocketSend_Cb = NULL;
+ }
+ }
+}
- if(psTransport->pSocketTable[index].bSocketAcceptPending == TRUE
- || psTransport->pSocketTable[index].bSocketConnectPending == TRUE
- || psTransport->pSocketTable[index].bSocketDiscPending == TRUE
- || psTransport->pSocketTable[index].bSocketRNRPending == TRUE
- || psTransport->pSocketTable[index].bSocketRRPending == TRUE
- || psTransport->pSocketTable[index].bSocketSendPending == TRUE
- || psTransport->pSocketTable[index].pfSocketSend_Cb != NULL)
- {
- /* socket found */
- socketFound = TRUE;
- psLocalLlcpSocket = &psTransport->pSocketTable[index];
- break;
- }
- else
- {
- if(index == psTransport->socketIndex)
- {
- break;
- }
- else
- {
- index ++;
- }
- }
- }while(index != ((psTransport->socketIndex+1)%PHFRINFC_LLCP_NB_SOCKET_MAX));
+NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_HandlePendingOperations(phFriNfc_LlcpTransport_Socket_t *pSocket)
+{
+ NFCSTATUS result = NFCSTATUS_FAILED;
+ phFriNfc_LlcpTransport_t *psTransport = pSocket->psTransport;
- if(socketFound == TRUE)
+ /* I FRAME */
+ if(pSocket->bSocketSendPending == TRUE)
+ {
+ /* Test the RW window */
+ if(CHECK_SEND_RW(pSocket))
{
- socketFound = FALSE;
- /* perform the command pending */
+ result = static_performSendInfo(pSocket);
+ }
+ }
+ /* RR FRAME */
+ else if(pSocket->bSocketRRPending == TRUE)
+ {
+ /* Reset RR pending */
+ pSocket->bSocketRRPending = FALSE;
- /* I FRAME */
- if(psLocalLlcpSocket->bSocketSendPending == TRUE)
- {
- /* Test the RW window */
- if(CHECK_SEND_RW(psLocalLlcpSocket))
- {
- result = static_performSendInfo(psLocalLlcpSocket);
+ /* Send RR Frame */
+ result = phFriNfc_Llcp_Send_ReceiveReady_Frame(pSocket);
+ }
+ /* RNR Frame */
+ else if(pSocket->bSocketRNRPending == TRUE)
+ {
+ /* Reset RNR pending */
+ pSocket->bSocketRNRPending = FALSE;
- /* Reset Send Pending Flag */
- psLocalLlcpSocket->bSocketSendPending = FALSE;
- }
- }
- /* RR FRAME */
- else if(psLocalLlcpSocket->bSocketRRPending == TRUE)
- {
- /* Reset RR pending */
- psLocalLlcpSocket->bSocketRRPending = FALSE;
+ /* Send RNR Frame */
+ result = phFriNfc_Llcp_Send_ReceiveNotReady_Frame(pSocket);
+ }
+ /* CC Frame */
+ else if(pSocket->bSocketAcceptPending == TRUE)
+ {
+ /* Reset Accept pending */
+ pSocket->bSocketAcceptPending = FALSE;
- /* Send RR Frame */
- result = phFriNfc_Llcp_Send_ReceiveReady_Frame(psLocalLlcpSocket);
- }
+ /* Fill the psLlcpHeader stuture with the DSAP,CC PTYPE and the SSAP */
+ pSocket->sLlcpHeader.dsap = pSocket->socket_dSap;
+ pSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_CC;
+ pSocket->sLlcpHeader.ssap = pSocket->socket_sSap;
- /* RNR Frame */
- else if(psLocalLlcpSocket->bSocketRNRPending == TRUE)
- {
- /* Reset RNR pending */
- psLocalLlcpSocket->bSocketRNRPending = FALSE;
+ /* Send Pending */
+ pSocket->psTransport->bSendPending = TRUE;
- /* Send RNR Frame */
- result = phFriNfc_Llcp_Send_ReceiveNotReady_Frame(psLocalLlcpSocket);
- }
- /* CC Frame */
- else if(psLocalLlcpSocket->bSocketAcceptPending == TRUE)
- {
- /* Reset Accept pending */
- psLocalLlcpSocket->bSocketAcceptPending = FALSE;
-
- /* Fill the psLlcpHeader stuture with the DSAP,CC PTYPE and the SSAP */
- psLocalLlcpSocket->sLlcpHeader.dsap = psLocalLlcpSocket->socket_dSap;
- psLocalLlcpSocket->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_CC;
- psLocalLlcpSocket->sLlcpHeader.ssap = psLocalLlcpSocket->socket_sSap;
-
- /* Set the socket state to accepted */
- psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketAccepted;
-
- /* Store the index of the socket */
- psTransport->socketIndex = psLocalLlcpSocket->index;
-
- /* Send a CC Frame */
- result = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psLocalLlcpSocket->sLlcpHeader,
- NULL,
- &psLocalLlcpSocket->sSocketSendBuffer,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
- }
- /* CONNECT FRAME */
- else if(psLocalLlcpSocket->bSocketConnectPending == TRUE)
- {
- /* Reset Accept pending */
- psLocalLlcpSocket->bSocketConnectPending = FALSE;
-
- /* Store the index of the socket */
- psTransport->socketIndex = psLocalLlcpSocket->index;
-
- /* Set the socket in connecting state */
- psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketConnecting;
-
- /* send CONNECT */
- result = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psLocalLlcpSocket->sLlcpHeader,
- NULL,
- &psLocalLlcpSocket->sSocketSendBuffer,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
- }
- /* DISC FRAME */
- else if(psLocalLlcpSocket->bSocketDiscPending == TRUE)
- {
- /* Reset Disc Pending */
- psLocalLlcpSocket->bSocketDiscPending = FALSE;
+ /* Set the socket state to accepted */
+ pSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketAccepted;
- /* Set the socket in connecting state */
- psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDisconnecting;
+ /* Send a CC Frame */
+ result = phFriNfc_LlcpTransport_LinkSend(psTransport,
+ &pSocket->sLlcpHeader,
+ NULL,
+ &pSocket->sSocketSendBuffer,
+ phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
+ psTransport);
+ }
+ /* CONNECT FRAME */
+ else if(pSocket->bSocketConnectPending == TRUE)
+ {
+ /* Reset Accept pending */
+ pSocket->bSocketConnectPending = FALSE;
- /* Store the index of the socket */
- psTransport->socketIndex = psLocalLlcpSocket->index;
+ /* Send Pending */
+ pSocket->psTransport->bSendPending = TRUE;
- /* Send DISC */
- result = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psLocalLlcpSocket->sLlcpHeader,
- NULL,
- &psLocalLlcpSocket->sSocketSendBuffer,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
+ /* Set the socket in connecting state */
+ pSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketConnecting;
- /* Call ErrCB due to a DISC */
- psLocalLlcpSocket->pSocketErrCb(psLocalLlcpSocket->pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
- }
- /* Call SEND IFRAME CB */
- else if((psLocalLlcpSocket->pfSocketSend_Cb != NULL) && !psLocalLlcpSocket->bSocketSendPending)
- {
- psLocalLlcpSocket->pfSocketSend_Cb(psLocalLlcpSocket->pSendContext,status);
- psLocalLlcpSocket->pfSocketSend_Cb = NULL;
- }
- }
- /* Reset the current length of the send buffer */
- //psTransport->pSocketTable[psTransport->socketIndex].sSocketSendBuffer.length = psTransport->pSocketTable[psTransport->socketIndex].bufferSendMaxLength;
+ /* send CONNECT */
+ result = phFriNfc_LlcpTransport_LinkSend(psTransport,
+ &pSocket->sLlcpHeader,
+ NULL,
+ &pSocket->sSocketSendBuffer,
+ phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
+ psTransport);
}
- else
+ /* DISC FRAME */
+ else if(pSocket->bSocketDiscPending == TRUE)
{
- /* Send CB error */
- 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;
- }
+ /* Reset Disc Pending */
+ pSocket->bSocketDiscPending = FALSE;
+
+ /* Send Pending */
+ pSocket->psTransport->bSendPending = TRUE;
+
+ /* Set the socket in connecting state */
+ pSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDisconnecting;
+
+ /* Send DISC */
+ result = phFriNfc_LlcpTransport_LinkSend(psTransport,
+ &pSocket->sLlcpHeader,
+ NULL,
+ &pSocket->sSocketSendBuffer,
+ phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
+ psTransport);
+
+ /* Call ErrCB due to a DISC */
+ pSocket->pSocketErrCb(pSocket->pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
}
+
+ return result;
}
static NFCSTATUS static_performSendInfo(phFriNfc_LlcpTransport_Socket_t * psLlcpSocket)
@@ -313,8 +230,8 @@ static NFCSTATUS static_performSendInfo(phFriNfc_LlcpTransport_Socket_t * psLlcp
phFriNfc_LlcpTransport_t *psTransport = psLlcpSocket->psTransport;
NFCSTATUS status;
- /* Reset Send Pending */
- psLlcpSocket->bSocketSendPending = FALSE;
+ /* Set transport send pending */
+ psTransport->bSendPending = TRUE;
/* Set the Header */
psLlcpSocket->sLlcpHeader.dsap = psLlcpSocket->socket_dSap;
@@ -332,16 +249,19 @@ static NFCSTATUS static_performSendInfo(phFriNfc_LlcpTransport_Socket_t * psLlcp
psTransport->socketIndex = psLlcpSocket->index;
/* Send I_PDU */
- status = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
+ status = phFriNfc_LlcpTransport_LinkSend(psTransport,
&psLlcpSocket->sLlcpHeader,
&psLlcpSocket->sSequence,
&psLlcpSocket->sSocketSendBuffer,
phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
+ psLlcpSocket->psTransport);
/* Update VS */
psLlcpSocket->socket_VS = (psLlcpSocket->socket_VS+1)%16;
+ /* Reset Send Pending */
+ psLlcpSocket->bSocketSendPending = FALSE;
+
return status;
}
@@ -383,49 +303,6 @@ static void phFriNfc_LlcpTransport_ConnectionOriented_Abort(phFriNfc_LlcpTranspo
pLlcpSocket->pListenContext = NULL;
}
-static NFCSTATUS phFriNfc_Llcp_Send_DisconnectMode_Frame(phFriNfc_LlcpTransport_t* psTransport,
- uint8_t dsap,
- uint8_t ssap,
- uint8_t dmOpCode)
-{
- NFCSTATUS status = NFCSTATUS_SUCCESS;
-
- /* Test if a send is pending */
- if(psTransport->bSendPending)
- {
- /* DM pending */
- psTransport->bDmPending = TRUE;
-
- /* Store DM Info */
- psTransport->DmInfoBuffer[0] = dsap;
- psTransport->DmInfoBuffer[1] = ssap;
- psTransport->DmInfoBuffer[2] = dmOpCode;
-
- status = NFCSTATUS_PENDING;
- }
- else
- {
- /* Set the header */
- psTransport->sDmHeader.dsap = dsap;
- psTransport->sDmHeader.ptype = PHFRINFC_LLCP_PTYPE_DM;
- psTransport->sDmHeader.ssap = ssap;
-
- /* Save Operation Code to be provided in DM frame payload */
- psTransport->DmInfoBuffer[2] = dmOpCode;
- psTransport->sDmPayload.buffer = &psTransport->DmInfoBuffer[2];
- psTransport->sDmPayload.length = PHFRINFC_LLCP_DM_LENGTH;
-
- /* Send DM frame */
- status = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psTransport->sDmHeader,
- NULL,
- &psTransport->sDmPayload,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
- }
-
- return status;
-}
static NFCSTATUS phFriNfc_Llcp_Send_ReceiveReady_Frame(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket)
{
@@ -455,7 +332,7 @@ static NFCSTATUS phFriNfc_Llcp_Send_ReceiveReady_Frame(phFriNfc_LlcpTransport_So
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
/* Send RR frame */
- status = phFriNfc_LlcpConnTransport_Send(pLlcpSocket->psTransport->pLlcp,
+ status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
&pLlcpSocket->sLlcpHeader,
&pLlcpSocket->sSequence,
NULL,
@@ -495,7 +372,7 @@ static NFCSTATUS phFriNfc_Llcp_Send_ReceiveNotReady_Frame(phFriNfc_LlcpTransport
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
/* Send RNR frame */
- status = phFriNfc_LlcpConnTransport_Send(pLlcpSocket->psTransport->pLlcp,
+ status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
&pLlcpSocket->sLlcpHeader,
&pLlcpSocket->sSequence,
NULL,
@@ -505,97 +382,6 @@ static NFCSTATUS phFriNfc_Llcp_Send_ReceiveNotReady_Frame(phFriNfc_LlcpTransport
return status;
}
-static NFCSTATUS phFriNfc_Llcp_Send_FrameReject_Frame(phFriNfc_LlcpTransport_t *psTransport,
- uint8_t dsap,
- uint8_t rejectedPTYPE,
- uint8_t ssap,
- phFriNfc_Llcp_sPacketSequence_t* sLlcpSequence,
- uint8_t WFlag,
- uint8_t IFlag,
- uint8_t RFlag,
- uint8_t SFlag,
- uint8_t vs,
- uint8_t vsa,
- uint8_t vr,
- uint8_t vra)
-{
- NFCSTATUS status = NFCSTATUS_SUCCESS;
- phNfc_sData_t sFrmrBuffer;
- uint8_t flagValue;
- uint8_t sequence = 0;
- uint8_t index;
- uint8_t socketFound = FALSE;
-
- /* Search a socket waiting for a FRAME */
- for(index=0;index<PHFRINFC_LLCP_NB_SOCKET_MAX;index++)
- {
- /* Test if the socket is in connected state and if its SSAP and DSAP are valid */
- if(psTransport->pSocketTable[index].socket_sSap == dsap
- && psTransport->pSocketTable[index].socket_dSap == ssap)
- {
- /* socket found */
- socketFound = TRUE;
- break;
- }
- }
-
- /* Test if a socket has been found */
- if(socketFound)
- {
- /* Set socket state to disconnected */
- psTransport->pSocketTable[index].eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDefault;
-
- /* Call ErrCB due to a FRMR*/
- psTransport->pSocketTable[index].pSocketErrCb( psTransport->pSocketTable[index].pContext,PHFRINFC_LLCP_ERR_FRAME_REJECTED);
-
- /* Close the socket */
- status = phFriNfc_LlcpTransport_ConnectionOriented_Close(&psTransport->pSocketTable[index]);
-
- /* Set FRMR Header */
- psTransport->sLlcpHeader.dsap = dsap;
- psTransport->sLlcpHeader.ptype = PHFRINFC_LLCP_PTYPE_FRMR;
- psTransport->sLlcpHeader.ssap = ssap;
-
- /* Set FRMR Information Field */
- flagValue = (WFlag<<7) | (IFlag<<6) | (RFlag<<5) | (SFlag<<4) | rejectedPTYPE;
- if (sLlcpSequence != NULL)
- {
- sequence = (uint8_t)((sLlcpSequence->ns<<4)|(sLlcpSequence->nr));
- }
-
- psTransport->FrmrInfoBuffer[0] = flagValue;
- psTransport->FrmrInfoBuffer[1] = sequence;
- psTransport->FrmrInfoBuffer[2] = (vs<<4)|vr ;
- psTransport->FrmrInfoBuffer[3] = (vsa<<4)|vra ;
-
- /* Test if a send is pending */
- if(psTransport->bSendPending)
- {
- psTransport->bFrmrPending = TRUE;
- status = NFCSTATUS_PENDING;
- }
- else
- {
- sFrmrBuffer.buffer = psTransport->FrmrInfoBuffer;
- sFrmrBuffer.length = 0x04; /* Size of FRMR Information field */
-
- /* Send FRMR frame */
- status = phFriNfc_LlcpConnTransport_Send(psTransport->pLlcp,
- &psTransport->sLlcpHeader,
- NULL,
- &sFrmrBuffer,
- phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
- psTransport);
- }
- }
- else
- {
- /* No active socket*/
- /* FRMR Frame not handled*/
- }
- return status;
-}
-
static NFCSTATUS phFriNfc_Llcp_GetSocket_Params(phNfc_sData_t *psParamsTLV,
phNfc_sData_t *psServiceName,
uint8_t *pRemoteRW_Size,
@@ -698,19 +484,19 @@ static void Handle_ConnectionFrame(phFriNfc_LlcpTransport_t *psTransport,
{
/* Incorrect TLV */
/* send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap,
- PHFRINFC_LLCP_PTYPE_CONNECT,
- dsap,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap,
+ PHFRINFC_LLCP_PTYPE_CONNECT,
+ dsap,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00);
}
else
{
@@ -829,20 +615,20 @@ static void Handle_ConnectionFrame(phFriNfc_LlcpTransport_t *psTransport,
{
/* No more socket are available */
/* Send a DM (0x21) */
- status = phFriNfc_Llcp_Send_DisconnectMode_Frame (psTransport,
- ssap,
- dsap,
- PHFRINFC_LLCP_DM_OPCODE_SOCKET_NOT_AVAILABLE);
+ status = phFriNfc_LlcpTransport_SendDisconnectMode (psTransport,
+ ssap,
+ dsap,
+ PHFRINFC_LLCP_DM_OPCODE_SOCKET_NOT_AVAILABLE);
}
}
else
{
/* Service Name not found or Port number not found */
/* Send a DM (0x02) */
- status = phFriNfc_Llcp_Send_DisconnectMode_Frame (psTransport,
- ssap,
- dsap,
- PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_FOUND);
+ status = phFriNfc_LlcpTransport_SendDisconnectMode (psTransport,
+ ssap,
+ dsap,
+ PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_FOUND);
}
}
@@ -868,19 +654,19 @@ static void Handle_ConnectionCompleteFrame(phFriNfc_LlcpTransport_t *psTran
{
/* Incorrect TLV */
/* send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap,
- PHFRINFC_LLCP_PTYPE_CC,
- dsap,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap,
+ PHFRINFC_LLCP_PTYPE_CC,
+ dsap,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00);
}
else
{
@@ -991,37 +777,18 @@ static void Handle_DisconnectFrame(phFriNfc_LlcpTransport_t *psTransport,
psLocalLlcpSocket->bSocketSendPending = FALSE;
}
- /* Test if a send is pending with this scoket */
- if(psTransport->bSendPending)
- {
- /* Set DM pending */
- psTransport->bDmPending = TRUE;
-
- /* Set the socket disconnecting */
- psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDisconnecting;
-
- /* Send pending, store the DISC request */
- psTransport->DmInfoBuffer[0] = ssap;
- psTransport->DmInfoBuffer[1] = dsap;
- psTransport->DmInfoBuffer[2] = PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED;
- }
- else
- {
- /* Set the socket disconnected */
- psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketCreated;
-
- /* Store the index of the socket */
- psTransport->socketIndex = psLocalLlcpSocket->index;
+ /* Update the socket state */
+ psLocalLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDisconnecting;
- /* Send a DM*/
- status = phFriNfc_Llcp_Send_DisconnectMode_Frame(psTransport,
- ssap,
- dsap,
- PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED);
+ /* Send a DM*/
+ /* TODO: use a socket internal flag to save */
+ status = phFriNfc_LlcpTransport_SendDisconnectMode(psTransport,
+ ssap,
+ dsap,
+ PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED);
- /* Call ErrCB due to a DISC */
- psTransport->pSocketTable[index].pSocketErrCb(psTransport->pSocketTable[index].pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
- }
+ /* Call ErrCB due to a DISC */
+ psTransport->pSocketTable[index].pSocketErrCb(psTransport->pSocketTable[index].pContext, PHFRINFC_LLCP_ERR_DISCONNECTED);
}
else
{
@@ -1046,19 +813,19 @@ static void Handle_DisconnetModeFrame(phFriNfc_LlcpTransport_t *psTransport
if(psData->length != PHFRINFC_LLCP_DM_LENGTH)
{
/* send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap,
- PHFRINFC_LLCP_PTYPE_DM,
- dsap,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap,
+ PHFRINFC_LLCP_PTYPE_DM,
+ dsap,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00);
}
else
{
@@ -1132,7 +899,7 @@ static void Handle_Receive_IFrame(phFriNfc_LlcpTransport_t *psTransport,
phFriNfc_LlcpTransport_Socket_t* psLocalLlcpSocket = NULL;
phFriNfc_Llcp_sPacketSequence_t sLlcpLocalSequence;
- uint32_t dataLengthAvailable = 0;
+ uint32_t dataLengthAvailable = 0;
uint32_t dataLengthWrite = 0;
uint8_t index;
uint8_t socketFound = FALSE;
@@ -1226,19 +993,19 @@ static void Handle_Receive_IFrame(phFriNfc_LlcpTransport_t *psTransport,
if( WFlag != 0 || IFlag != 0 || RFlag != 0 || SFlag != 0)
{
/* Send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap,
- PHFRINFC_LLCP_PTYPE_I,
- dsap,
- &sLlcpLocalSequence,
- WFlag,
- IFlag,
- RFlag,
- SFlag,
- psLocalLlcpSocket->socket_VS,
- psLocalLlcpSocket->socket_VSA,
- psLocalLlcpSocket->socket_VR,
- psLocalLlcpSocket->socket_VRA);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap,
+ PHFRINFC_LLCP_PTYPE_I,
+ dsap,
+ &sLlcpLocalSequence,
+ WFlag,
+ IFlag,
+ RFlag,
+ SFlag,
+ psLocalLlcpSocket->socket_VS,
+ psLocalLlcpSocket->socket_VSA,
+ psLocalLlcpSocket->socket_VR,
+ psLocalLlcpSocket->socket_VRA);
}
else
@@ -1456,14 +1223,14 @@ static void Handle_ReceiveReady_Frame(phFriNfc_LlcpTransport_t *psTransport
if (WFlag || IFlag || RFlag || SFlag)
{
/* Send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap, PHFRINFC_LLCP_PTYPE_RR, dsap,
- &sLlcpLocalSequence,
- WFlag, IFlag, RFlag, SFlag,
- psLocalLlcpSocket->socket_VS,
- psLocalLlcpSocket->socket_VSA,
- psLocalLlcpSocket->socket_VR,
- psLocalLlcpSocket->socket_VRA);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap, PHFRINFC_LLCP_PTYPE_RR, dsap,
+ &sLlcpLocalSequence,
+ WFlag, IFlag, RFlag, SFlag,
+ psLocalLlcpSocket->socket_VS,
+ psLocalLlcpSocket->socket_VSA,
+ psLocalLlcpSocket->socket_VR,
+ psLocalLlcpSocket->socket_VRA);
}
else
{
@@ -1571,14 +1338,14 @@ static void Handle_ReceiveNotReady_Frame(phFriNfc_LlcpTransport_t *psTransp
if( bWFlag != 0 || bIFlag != 0 || bRFlag != 0 || bSFlag != 0)
{
/* Send FRMR */
- status = phFriNfc_Llcp_Send_FrameReject_Frame(psTransport,
- ssap, PHFRINFC_LLCP_PTYPE_RNR, dsap,
- &sLlcpLocalSequence,
- bWFlag, bIFlag, bRFlag, bSFlag,
- psLocalLlcpSocket->socket_VS,
- psLocalLlcpSocket->socket_VSA,
- psLocalLlcpSocket->socket_VR,
- psLocalLlcpSocket->socket_VRA);
+ status = phFriNfc_LlcpTransport_SendFrameReject(psTransport,
+ ssap, PHFRINFC_LLCP_PTYPE_RNR, dsap,
+ &sLlcpLocalSequence,
+ bWFlag, bIFlag, bRFlag, bSFlag,
+ psLocalLlcpSocket->socket_VS,
+ psLocalLlcpSocket->socket_VSA,
+ psLocalLlcpSocket->socket_VR,
+ psLocalLlcpSocket->socket_VRA);
}
else
{
@@ -1723,13 +1490,12 @@ void Handle_ConnectionOriented_IncommingFrame(phFriNfc_LlcpTransport_t
case PHFRINFC_LLCP_PTYPE_RESERVED1:
case PHFRINFC_LLCP_PTYPE_RESERVED2:
case PHFRINFC_LLCP_PTYPE_RESERVED3:
- case PHFRINFC_LLCP_PTYPE_RESERVED4:
{
- phFriNfc_Llcp_Send_FrameReject_Frame( psTransport,
- dsap, ptype, ssap,
- &sSequence,
- TRUE, FALSE, FALSE, FALSE,
- 0, 0, 0, 0);
+ phFriNfc_LlcpTransport_SendFrameReject( psTransport,
+ dsap, ptype, ssap,
+ &sSequence,
+ TRUE, FALSE, FALSE, FALSE,
+ 0, 0, 0, 0);
}break;
}
}
@@ -2034,7 +1800,7 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Accept(phFriNfc_LlcpTranspor
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
/* Send a CC Frame */
- status = phFriNfc_LlcpConnTransport_Send(pLlcpSocket->psTransport->pLlcp,
+ status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
&pLlcpSocket->sLlcpHeader,
NULL,
&pLlcpSocket->sSocketSendBuffer,
@@ -2085,10 +1851,10 @@ NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Reject( phFriNfc_LlcpTranspo
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
/* Send a DM*/
- status = phFriNfc_Llcp_Send_DisconnectMode_Frame(pLlcpSocket->psTransport,
- pLlcpSocket->socket_dSap,
- pLlcpSocket->socket_sSap,
- PHFRINFC_LLCP_DM_OPCODE_CONNECT_REJECTED);
+ status = phFriNfc_LlcpTransport_SendDisconnectMode(pLlcpSocket->psTransport,
+ pLlcpSocket->socket_dSap,
+ pLlcpSocket->socket_sSap,
+ PHFRINFC_LLCP_DM_OPCODE_CONNECT_REJECTED);
return status;
}
@@ -2224,7 +1990,8 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransp
/* Store the index of the socket */
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
- status = phFriNfc_LlcpConnTransport_Send(pLlcpSocket->psTransport->pLlcp,
+
+ status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
&pLlcpSocket->sLlcpHeader,
NULL,
&pLlcpSocket->sSocketSendBuffer,
@@ -2328,7 +2095,7 @@ NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(phFriNfc_LlcpTran
/* Store the index of the socket */
pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index;
- status = phFriNfc_LlcpConnTransport_Send(pLlcpSocket->psTransport->pLlcp,
+ status = phFriNfc_LlcpTransport_LinkSend(pLlcpSocket->psTransport,
&pLlcpSocket->sLlcpHeader,
NULL,
NULL,
@@ -2513,8 +2280,12 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Send(phFriNfc_LlcpTransport_
}
else
{
- /* Perform I-Frame send */
+ /* Store the Send CB and context */
+ pLlcpSocket->pfSocketSend_Cb = pSend_RspCb;
+ pLlcpSocket->pSendContext = pContext;
+
status = static_performSendInfo(pLlcpSocket);
+
if(status != NFCSTATUS_PENDING)
{
LLCP_PRINT("Release Send callback");