phFriNfc_LlcpTransport.c revision 407d793f3038222dac95651866b99cd064e214eb
15d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 25d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Copyright (C) 2010 NXP Semiconductors 35d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 45d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Licensed under the Apache License, Version 2.0 (the "License"); 55d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * you may not use this file except in compliance with the License. 65d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * You may obtain a copy of the License at 75d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 85d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * http://www.apache.org/licenses/LICENSE-2.0 95d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Unless required by applicable law or agreed to in writing, software 115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * distributed under the License is distributed on an "AS IS" BASIS, 125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * See the License for the specific language governing permissions and 145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * limitations under the License. 155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \file phFriNfc_LlcpTransport.c 195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief 205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Project: NFC-FRI 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*include files*/ 26cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau#include <phOsalNfc.h> 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfcStatus.h> 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLibNfc.h> 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcLlcpTypes.h> 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phFriNfc_Llcp.h> 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phFriNfc_LlcpTransport.h> 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phFriNfc_LlcpTransport_Connectionless.h> 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phFriNfc_LlcpTransport_Connection.h> 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* TODO: comment function Transport recv CB */ 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phFriNfc_LlcpTransport__Recv_CB(void *pContext, 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *psData, 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status) 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_sPacketHeader_t sLlcpLocalHeader; 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t dsap; 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t ptype; 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t ssap; 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport_t* pLlcpTransport = (phFriNfc_LlcpTransport_t*)pContext; 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status != NFCSTATUS_SUCCESS) 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->LinkStatusError = TRUE; 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_Buffer2Header( psData->buffer,0x00, &sLlcpLocalHeader); 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly dsap = (uint8_t)sLlcpLocalHeader.dsap; 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ptype = (uint8_t)sLlcpLocalHeader.ptype; 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ssap = (uint8_t)sLlcpLocalHeader.ssap; 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the length value (without the header length) */ 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psData->length = psData->length - PHFRINFC_LLCP_PACKET_HEADER_SIZE; 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the buffer pointer */ 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psData->buffer = psData->buffer + PHFRINFC_LLCP_PACKET_HEADER_SIZE; 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(ptype) 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Connectionless */ 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_UI: 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Handle_Connectionless_IncommingFrame(pLlcpTransport, 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psData, 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly dsap, 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ssap); 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }break; 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Connection oriented */ 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* NOTE: forward reserved PTYPE to enable FRMR sending */ 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_CONNECT: 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_CC: 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_DISC: 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_DM: 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_I: 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RR: 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RNR: 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_FRMR: 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RESERVED1: 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RESERVED2: 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RESERVED3: 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PHFRINFC_LLCP_PTYPE_RESERVED4: 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Handle_ConnectionOriented_IncommingFrame(pLlcpTransport, 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psData, 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly dsap, 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ptype, 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ssap); 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }break; 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }break; 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Restart the Receive Loop */ 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_Llcp_Recv(pLlcpTransport->pLlcp, 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport__Recv_CB, 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport); 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* TODO: comment function Transport reset */ 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Reset (phFriNfc_LlcpTransport_t *pLlcpTransport, 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_t *pLlcp) 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i; 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpTransport == NULL || pLlcp == NULL) 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset Transport structure */ 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pLlcp = pLlcp; 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->LinkStatusError = FALSE; 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->bSendPending = FALSE; 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->bRecvPending = FALSE; 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->bDmPending = FALSE; 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->bFrmrPending = FALSE; 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->socketIndex = FALSE; 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->LinkStatusError = 0; 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Reset all the socket info in the table */ 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++) 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].eSocket_State = phFriNfc_LlcpTransportSocket_eSocketDefault; 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].eSocket_Type = phFriNfc_LlcpTransport_eDefaultType; 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].index = i; 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pContext = NULL; 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pListenContext = NULL; 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pAcceptContext = NULL; 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pRejectContext = NULL; 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pConnectContext = NULL; 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pDisonnectContext = NULL; 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pSendContext = NULL; 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pRecvContext = NULL; 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pSocketErrCb = NULL; 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bufferLinearLength = 0; 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bufferSendMaxLength = 0; 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bufferRwMaxLength = 0; 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].ReceiverBusyCondition = FALSE; 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].RemoteBusyConditionInfo = FALSE; 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_sSap = PHFRINFC_LLCP_SAP_DEFAULT; 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_dSap = PHFRINFC_LLCP_SAP_DEFAULT; 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketRecvPending = FALSE; 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketSendPending = FALSE; 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketListenPending = FALSE; 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketDiscPending = FALSE; 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketConnectPending = FALSE; 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketAcceptPending = FALSE; 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketRRPending = FALSE; 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].bSocketRNRPending = FALSE; 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].psTransport = pLlcpTransport; 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketSend_Cb = NULL; 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketRecv_Cb = NULL; 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketRecvFrom_Cb = NULL; 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketListen_Cb = NULL; 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketConnect_Cb = NULL; 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].pfSocketDisconnect_Cb = NULL; 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_VS = 0; 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_VSA = 0; 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_VR = 0; 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].socket_VRA = 0; 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].remoteRW = 0; 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].localRW = 0; 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].remoteMIU = 0; 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].localMIUX = 0; 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].index = 0; 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].indexRwRead = 0; 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[i].indexRwWrite = 0; 185cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau 186c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau memset(&pLlcpTransport->pSocketTable[i].sSocketOption, 0x00, sizeof(phFriNfc_LlcpTransport_sSocketOptions_t)); 187c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau 188cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau if (pLlcpTransport->pSocketTable[i].sServiceName.buffer != NULL) { 189cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau phOsalNfc_FreeMemory(pLlcpTransport->pSocketTable[i].sServiceName.buffer); 190cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau } 191cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau pLlcpTransport->pSocketTable[i].sServiceName.buffer = NULL; 192cf5cd1520ea32d2b65712a36a105f396df07345cSylvain Fonteneau pLlcpTransport->pSocketTable[i].sServiceName.length = 0; 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Start The Receive Loop */ 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_Llcp_Recv(pLlcpTransport->pLlcp, 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport__Recv_CB, 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport); 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 203c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau/* TODO: comment function Transport CloseAll */ 204c56a3c7bc332a6656bedf342236267b636051170Sylvain FonteneauNFCSTATUS phFriNfc_LlcpTransport_CloseAll (phFriNfc_LlcpTransport_t *pLlcpTransport) 205c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau{ 206c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau NFCSTATUS status = NFCSTATUS_SUCCESS; 207c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau uint8_t i; 208c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau 209c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau /* Check for NULL pointers */ 210c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau if(pLlcpTransport == NULL) 211c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau { 212c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 213c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau } 214c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau 215c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau /* Close all sockets */ 216c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++) 217c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau { 21876270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir if(pLlcpTransport->pSocketTable[i].eSocket_Type == phFriNfc_LlcpTransport_eConnectionOriented) 21976270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir { 22076270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir switch(pLlcpTransport->pSocketTable[i].eSocket_State) 22176270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir { 22276270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketConnected: 22376270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketConnecting: 22476270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketAccepted: 22576270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketDisconnected: 22676270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketDisconnecting: 22776270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir case phFriNfc_LlcpTransportSocket_eSocketRejected: 22876270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir phFriNfc_LlcpTransport_Close(&pLlcpTransport->pSocketTable[i]); 22976270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir break; 23076270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir } 23176270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir } 23276270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir else 23376270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir { 23476270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir phFriNfc_LlcpTransport_Close(&pLlcpTransport->pSocketTable[i]); 23576270e7c32ec0c558907430e756712d5b68b417cArnaud Ferir } 236c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau } 237c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau 238c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau return status; 239c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau} 240c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau 241c56a3c7bc332a6656bedf342236267b636051170Sylvain Fonteneau 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_lib_nfc 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Get the local options of a socket</b>. 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function returns the local options (maximum packet size and receive window size) used 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* for a given connection-oriented socket. This function shall not be used with connectionless 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* sockets. 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psLocalOptions A pointer to be filled with the local options of the socket. 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_SocketGetLocalOptions(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Llcp_sSocketOptions_t *psLocalOptions) 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (pLlcpSocket == NULL || psLocalOptions == NULL) 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket type */ 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket state */ 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State == phFriNfc_LlcpTransportSocket_eSocketDefault) 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_SocketGetLocalOptions(pLlcpSocket, 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psLocalOptions); 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_lib_nfc 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Get the local options of a socket</b>. 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function returns the remote options (maximum packet size and receive window size) used 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* for a given connection-oriented socket. This function shall not be used with connectionless 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* sockets. 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psRemoteOptions A pointer to be filled with the remote options of the socket. 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_SocketGetRemoteOptions(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phLibNfc_Llcp_sSocketOptions_t* psRemoteOptions) 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (pLlcpSocket == NULL || psRemoteOptions == NULL) 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket type */ 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket state */ 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketConnected) 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_SocketGetRemoteOptions(pLlcpSocket, 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psRemoteOptions); 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /** 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Create a socket on a LLCP-connected device</b>. 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function creates a socket for a given LLCP link. Sockets can be of two types : 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* connection-oriented and connectionless. If the socket is connection-oriented, the caller 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* must provide a working buffer to the socket in order to handle incoming data. This buffer 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* must be large enough to fit the receive window (RW * MIU), the remaining space being 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* used as a linear buffer to store incoming data as a stream. Data will be readable later 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* using the phLibNfc_LlcpTransport_Recv function. 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* The options and working buffer are not required if the socket is used as a listening socket, 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* since it cannot be directly used for communication. 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocketTable A pointer to a table of PHFRINFC_LLCP_NB_SOCKET_DEFAULT sockets. 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] eType The socket type. 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psOptions The options to be used with the socket. 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psWorkingBuffer A working buffer to be used by the library. 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[out] pLlcpSocket A pointer on the socket to be filled with a 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly socket found on the socket table. 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pErr_Cb The callback to be called each time the socket 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* is in error. 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in the callback. 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* declared in the options. 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INSUFFICIENT_RESOURCES No more socket handle available. 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* */ 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Socket(phFriNfc_LlcpTransport_t *pLlcpTransport, 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport_eSocketType_t eType, 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport_sSocketOptions_t *psOptions, 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *psWorkingBuffer, 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport_Socket_t **pLlcpSocket, 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketErrCb_t pErr_Cb, 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_sLinkParameters_t LlcpLinkParamInfo; 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t index=0; 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t cpt; 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (((NULL == psOptions) && (eType != phFriNfc_LlcpTransport_eConnectionLess)) || ((psWorkingBuffer == NULL) && (eType != phFriNfc_LlcpTransport_eConnectionLess)) || pLlcpSocket == NULL || pErr_Cb == NULL || pContext == NULL || pLlcpTransport == NULL) 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket type*/ 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(eType != phFriNfc_LlcpTransport_eConnectionOriented && eType != phFriNfc_LlcpTransport_eConnectionLess) 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the local parameters of the LLCP Link */ 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_Llcp_GetLocalInfo(pLlcpTransport->pLlcp,&LlcpLinkParamInfo); 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status != NFCSTATUS_SUCCESS) 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED); 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Search a socket free in the Socket Table*/ 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly do 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpTransport->pSocketTable[index].eSocket_State == phFriNfc_LlcpTransportSocket_eSocketDefault) 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the socket pointer to socket of the table */ 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *pLlcpSocket = &pLlcpTransport->pSocketTable[index]; 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the socket info in the socket pointer */ 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].eSocket_Type = eType; 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].pSocketErrCb = pErr_Cb; 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store the context of the upper layer */ 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].pContext = pContext; 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the pointers to the different working buffers */ 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpTransport->pSocketTable[index].eSocket_Type != phFriNfc_LlcpTransport_eConnectionLess) 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket options */ 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((psOptions->rw > PHFRINFC_LLCP_RW_MAX) && (eType == phFriNfc_LlcpTransport_eConnectionOriented)) 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set socket options */ 430c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau memcpy(&pLlcpTransport->pSocketTable[index].sSocketOption, psOptions, sizeof(phFriNfc_LlcpTransport_sSocketOptions_t)); 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set socket local params (MIUX & RW) */ 433c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau pLlcpTransport->pSocketTable[index].localMIUX = (pLlcpTransport->pSocketTable[index].sSocketOption.miu - PHFRINFC_LLCP_MIU_DEFAULT) & PHFRINFC_LLCP_TLV_MIUX_MASK; 434c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau pLlcpTransport->pSocketTable[index].localRW = pLlcpTransport->pSocketTable[index].sSocketOption.rw & PHFRINFC_LLCP_TLV_RW_MASK; 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the Max length for the Send and Receive Window Buffer */ 437c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau pLlcpTransport->pSocketTable[index].bufferSendMaxLength = pLlcpTransport->pSocketTable[index].sSocketOption.miu; 438c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau pLlcpTransport->pSocketTable[index].bufferRwMaxLength = pLlcpTransport->pSocketTable[index].sSocketOption.miu * ((pLlcpTransport->pSocketTable[index].sSocketOption.rw & PHFRINFC_LLCP_TLV_RW_MASK)); 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].bufferLinearLength = psWorkingBuffer->length - pLlcpTransport->pSocketTable[index].bufferSendMaxLength - pLlcpTransport->pSocketTable[index].bufferRwMaxLength; 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the connection oriented buffers length */ 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((pLlcpTransport->pSocketTable[index].bufferSendMaxLength + pLlcpTransport->pSocketTable[index].bufferRwMaxLength) > psWorkingBuffer->length 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ((pLlcpTransport->pSocketTable[index].bufferLinearLength < PHFRINFC_LLCP_MIU_DEFAULT) && (pLlcpTransport->pSocketTable[index].bufferLinearLength != 0))) 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_BUFFER_TOO_SMALL); 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the pointer and the length for the Receive Window Buffer */ 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(cpt=0;cpt<pLlcpTransport->pSocketTable[index].localRW;cpt++) 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 452c2866714540bec65af19240e95a10d3090df0cf9Sylvain Fonteneau pLlcpTransport->pSocketTable[index].sSocketRwBufferTable[cpt].buffer = psWorkingBuffer->buffer + (cpt*pLlcpTransport->pSocketTable[index].sSocketOption.miu); 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketRwBufferTable[cpt].length = 0; 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the pointer and the length for the Send Buffer */ 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketSendBuffer.buffer = psWorkingBuffer->buffer + pLlcpTransport->pSocketTable[index].bufferRwMaxLength; 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketSendBuffer.length = pLlcpTransport->pSocketTable[index].bufferSendMaxLength; 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /** Set the pointer and the length for the Linear Buffer */ 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketLinearBuffer.buffer = psWorkingBuffer->buffer + pLlcpTransport->pSocketTable[index].bufferRwMaxLength + pLlcpTransport->pSocketTable[index].bufferSendMaxLength; 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketLinearBuffer.length = pLlcpTransport->pSocketTable[index].bufferLinearLength; 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpTransport->pSocketTable[index].sSocketLinearBuffer.length != 0) 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Init Cyclic Fifo */ 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_CyclicFifoInit(&pLlcpTransport->pSocketTable[index].sCyclicFifoBuffer, 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketLinearBuffer.buffer, 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].sSocketLinearBuffer.length); 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Store index of the socket */ 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].index = index; 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the socket into created state */ 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpTransport->pSocketTable[index].eSocket_State = phFriNfc_LlcpTransportSocket_eSocketCreated; 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly index++; 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }while(index<PHFRINFC_LLCP_NB_SOCKET_MAX); 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INSUFFICIENT_RESOURCES); 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Close a socket on a LLCP-connected device</b>. 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket. 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* If the socket was connected, it is first disconnected, and then closed. 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Close(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket) 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( pLlcpSocket == NULL) 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type == phFriNfc_LlcpTransport_eConnectionOriented) 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Close(pLlcpSocket); 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type == phFriNfc_LlcpTransport_eConnectionLess) 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_Connectionless_Close(pLlcpSocket); 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Bind a socket to a local SAP</b>. 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function binds the socket to a local Service Access Point. 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pConfigInfo A port number for a specific socket 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_ALREADY_REGISTERED The selected SAP is already bound to another 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly socket. 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Bind(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t nSap) 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i; 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL) 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketCreated) 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(nSap<2 || nSap>63) 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the nSap it is useb by another socket */ 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++) 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((pLlcpSocket->psTransport->pSocketTable[i].socket_sSap == nSap) 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (pLlcpSocket->psTransport->pSocketTable[i].eSocket_Type == pLlcpSocket->eSocket_Type)) 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_ALREADY_REGISTERED); 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the nSap value of the socket */ 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->socket_sSap = nSap; 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Set the socket state */ 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketBound; 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*********************************************/ 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* ConnectionOriented */ 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*********************************************/ 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Listen for incoming connection requests on a socket</b>. 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function switches a socket into a listening state and registers a callback on 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* incoming connection requests. In this state, the socket is not able to communicate 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* directly. The listening state is only available for connection-oriented sockets 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* which are still not connected. The socket keeps listening until it is closed, and 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* thus can trigger several times the pListen_Cb callback. 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psServiceName A pointer to Service Name 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pListen_Cb The callback to be called each time the 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* socket receive a connection request. 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state to switch 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* to listening state. 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Listen(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *psServiceName, 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketListenCb_t pListen_Cb, 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || pListen_Cb == NULL|| pContext == NULL || psServiceName == NULL) 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket state */ 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket type */ 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if a listen is not pending with this socket */ 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->bSocketListenPending) 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the length of the SN */ 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(psServiceName->length > PHFRINFC_LLCP_SN_MAX_LENGTH) 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 645a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Listen(pLlcpSocket, 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psServiceName, 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pListen_Cb, 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Accept an incoming connection request for a socket</b>. 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This functions allows the client to accept an incoming connection request. 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* It must be used with the socket provided within the listen callback. The socket 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* is implicitly switched to the connected state when the function is called. 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psOptions The options to be used with the socket. 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psWorkingBuffer A working buffer to be used by the library. 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pErr_Cb The callback to be called each time the accepted socket 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* is in error. 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in the callback. 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* declared in the options. 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Accept(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_LlcpTransport_sSocketOptions_t* psOptions, 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t* psWorkingBuffer, 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketErrCb_t pErr_Cb, 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketAcceptCb_t pAccept_RspCb, 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || psOptions == NULL || psWorkingBuffer == NULL || pErr_Cb == NULL || pContext == NULL) 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket state */ 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket type */ 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the socket options */ 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(psOptions->rw > PHFRINFC_LLCP_RW_MAX) 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 710a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir /* Set the Max length for the Send and Receive Window Buffer */ 711a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pLlcpSocket->bufferSendMaxLength = psOptions->miu; 712a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pLlcpSocket->bufferRwMaxLength = psOptions->miu * ((psOptions->rw & PHFRINFC_LLCP_TLV_RW_MASK)); 713a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pLlcpSocket->bufferLinearLength = psWorkingBuffer->length - pLlcpSocket->bufferSendMaxLength - pLlcpSocket->bufferRwMaxLength; 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 715a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir /* Test the buffers length */ 716a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir if((pLlcpSocket->bufferSendMaxLength + pLlcpSocket->bufferRwMaxLength) > psWorkingBuffer->length 717a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir || ((pLlcpSocket->bufferLinearLength < PHFRINFC_LLCP_MIU_DEFAULT) && (pLlcpSocket->bufferLinearLength != 0))) 718a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 719a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_BUFFER_TOO_SMALL); 720a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 721a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir else 722a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 723a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pLlcpSocket->psTransport->socketIndex = pLlcpSocket->index; 724a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir 725a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = phFriNfc_LlcpTransport_ConnectionOriented_Accept(pLlcpSocket, 726a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir psOptions, 727a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir psWorkingBuffer, 728a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pErr_Cb, 729a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pAccept_RspCb, 730a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pContext); 731a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /** 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Reject an incoming connection request for a socket</b>. 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This functions allows the client to reject an incoming connection request. 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* It must be used with the socket provided within the listen callback. The socket 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* is implicitly closed when the function is called. 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pReject_RspCb The callback to be call when the Reject operation is completed 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in the callback. 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Reject( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketRejectCb_t pReject_RspCb, 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext) 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL) 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket state */ 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for socket type */ 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phLibNfc_LlcpTransport_ConnectionOriented_Reject(pLlcpSocket, 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pReject_RspCb, 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Try to establish connection with a socket on a remote SAP</b>. 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function tries to connect to a given SAP on the remote peer. If the 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* socket is not bound to a local SAP, it is implicitly bound to a free SAP. 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] nSap The destination SAP to connect to. 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pConnect_RspCb The callback to be called when the connection 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Connection operation is in progress, 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pConnect_RspCb will be called upon completion. 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Connect( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t nSap, 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketConnectCb_t pConnect_RspCb, 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i; 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 81599e7261d709ad32e0203dced9f4a386c5f719adfArnaud Ferir /* Check for NULL pointers */ 816a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir if(pLlcpSocket == NULL || pConnect_RspCb == NULL || pContext == NULL) 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the port number value */ 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(nSap<02 || nSap>63) 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionOriented socket */ 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is not in connecting or connected state*/ 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketCreated && pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Bind with a sSap Free */ 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->socket_sSap = 32; 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++) 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket->socket_sSap == pLlcpSocket->psTransport->pSocketTable[i].socket_sSap) 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->socket_sSap++; 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->eSocket_State = phFriNfc_LlcpTransportSocket_eSocketBound; 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Connect(pLlcpSocket, 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly nSap, 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NULL, 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pConnect_RspCb, 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Try to establish connection with a socket on a remote service, given its URI</b>. 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function tries to connect to a SAP designated by an URI. If the 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* socket is not bound to a local SAP, it is implicitly bound to a free SAP. 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psUri The URI corresponding to the destination SAP to connect to. 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pConnect_RspCb The callback to be called when the connection 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Connection operation is in progress, 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pConnect_RspCb will be called upon completion. 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_ConnectByUri(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t* psUri, 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketConnectCb_t pConnect_RspCb, 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i; 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || pConnect_RspCb == NULL || pContext == NULL) 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionOriented socket */ 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is not in connect pending or connected state*/ 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State == phFriNfc_LlcpTransportSocket_eSocketConnecting || pLlcpSocket->eSocket_State == phFriNfc_LlcpTransportSocket_eSocketConnected) 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the length of the SN */ 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(psUri->length > PHFRINFC_LLCP_SN_MAX_LENGTH) 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 914a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Bind with a sSap Free */ 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->socket_sSap = 32; 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0;i<PHFRINFC_LLCP_NB_SOCKET_MAX;i++) 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket->socket_sSap == pLlcpSocket->psTransport->pSocketTable[i].socket_sSap) 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pLlcpSocket->socket_sSap++; 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Connect(pLlcpSocket, 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHFRINFC_LLCP_SAP_DEFAULT, 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psUri, 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pConnect_RspCb, 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 937a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_lib_nfc 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Disconnect a currently connected socket</b>. 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function initiates the disconnection of a previously connected socket. 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pDisconnect_RspCb The callback to be called when the 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Disconnection operation is in progress, 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pDisconnect_RspCb will be called upon completion. 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Disconnect(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphLibNfc_LlcpSocketDisconnectCb_t pDisconnect_RspCb, 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || pDisconnect_RspCb == NULL || pContext == NULL) 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionOriented socket */ 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 978a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is connected state*/ 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketConnected) 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(pLlcpSocket, 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pDisconnect_RspCb, 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Send data on a socket</b>. 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function is used to write data on a socket. This function 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* can only be called on a connection-oriented socket which is already 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* in a connected state. 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psBuffer The buffer containing the data to send. 10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pSend_RspCb The callback to be called when the 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Reception operation is in progress, 10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pSend_RspCb will be called upon completion. 10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Send(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t* psBuffer, 10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, 10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || psBuffer == NULL || pSend_RspCb == NULL || pContext == NULL) 10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionOriented socket */ 10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is in connected state */ 10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketConnected) 10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the length of the buffer */ 10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(psBuffer->length > pLlcpSocket->remoteMIU ) 10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if a send is pending */ 1048407d793f3038222dac95651866b99cd064e214ebArnaud Ferir else if(pLlcpSocket->pfSocketSend_Cb != NULL) 10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_REJECTED); 10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Send(pLlcpSocket, 10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psBuffer, 10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pSend_RspCb, 10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /** 10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Read data on a socket</b>. 10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function is used to read data from a socket. It reads at most the 10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* size of the reception buffer, but can also return less bytes if less bytes 10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* are available. If no data is available, the function will be pending until 10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* more data comes, and the response will be sent by the callback. This function 10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* can only be called on a connection-oriented socket. 10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. 10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psBuffer The buffer receiving the data. 10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pRecv_RspCb The callback to be called when the 10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Reception operation is in progress, 10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pRecv_RspCb will be called upon completion. 10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_Recv( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, 10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t* psBuffer, 10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketRecvCb_t pRecv_RspCb, 10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Check for NULL pointers */ 10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || psBuffer == NULL || pRecv_RspCb == NULL || pContext == NULL) 10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionOriented socket */ 11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionOriented) 11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is in connected state */ 110804f25b3ab4ed13edb3ffc8e7354bca9f7bc60b44Sylvain Fonteneau else if(pLlcpSocket->eSocket_State == phFriNfc_LlcpTransportSocket_eSocketDefault) 11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if a receive is pending */ 11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->bSocketRecvPending == TRUE) 11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_REJECTED); 11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phFriNfc_LlcpTransport_ConnectionOriented_Recv(pLlcpSocket, 11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psBuffer, 11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pRecv_RspCb, 11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*****************************************/ 11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* ConnectionLess */ 11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*****************************************/ 11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_fri_nfc 11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Send data on a socket to a given destination SAP</b>. 11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function is used to write data on a socket to a given destination SAP. 11375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function can only be called on a connectionless socket. 11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a LlcpSocket created. 11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] nSap The destination SAP. 11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psBuffer The buffer containing the data to send. 11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pSend_RspCb The callback to be called when the 11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Reception operation is in progress, 11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pSend_RspCb will be called upon completion. 11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_SendTo( phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t nSap, 11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *psBuffer, 11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, 11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phFriNfc_Llcp_sLinkParameters_t LlcpRemoteLinkParamInfo; 11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || psBuffer == NULL || pSend_RspCb == NULL || pContext == NULL) 11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test the port number value */ 11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(nSap<2 || nSap>63) 11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionless socket */ 11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionLess) 11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is in an updated state */ 11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1187a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir /* Get the local parameters of the LLCP Link */ 1188a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = phFriNfc_Llcp_GetRemoteInfo(pLlcpSocket->psTransport->pLlcp,&LlcpRemoteLinkParamInfo); 1189a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir if(status != NFCSTATUS_SUCCESS) 1190a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 1191a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED); 1192a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 1193a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir /* Test the length of the socket buffer for ConnectionLess mode*/ 1194a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir else if(psBuffer->length > LlcpRemoteLinkParamInfo.miu) 1195a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 1196a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 1197a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 1198a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir /* Test if the link is in error state */ 1199a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir else if(pLlcpSocket->psTransport->LinkStatusError) 1200a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 1201a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_REJECTED); 1202a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 1203a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir else 1204a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir { 1205a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = phFriNfc_LlcpTransport_Connectionless_SendTo(pLlcpSocket, 1206a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir nSap, 1207a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir psBuffer, 1208a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pSend_RspCb, 1209a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir pContext); 1210a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir } 12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1212a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir 12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /** 12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \ingroup grp_lib_nfc 12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief <b>Read data on a socket and get the source SAP</b>. 12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function is the same as phLibNfc_Llcp_Recv, except that the callback includes 12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the source SAP. This functions can only be called on a connectionless socket. 12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pLlcpSocket A pointer to a LlcpSocket created. 12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] psBuffer The buffer receiving the data. 12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pRecv_RspCb The callback to be called when the 12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* operation is completed. 12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \param[in] pContext Upper layer context to be returned in 12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* the callback. 12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SUCCESS Operation successful. 12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters 12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* could not be properly interpreted. 12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_PENDING Reception operation is in progress, 12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* pRecv_RspCb will be called upon completion. 12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of 12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* a valid type to perform the requsted operation. 12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. 12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. 12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \retval NFCSTATUS_FAILED Operation failed. 12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phFriNfc_LlcpTransport_RecvFrom( phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, 12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t* psBuffer, 12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphFriNfc_LlcpTransportSocketRecvFromCb_t pRecv_Cb, 12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void* pContext) 12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket == NULL || psBuffer == NULL || pRecv_Cb == NULL || pContext == NULL) 12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is a connectionless socket */ 12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_Type != phFriNfc_LlcpTransport_eConnectionLess) 12555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1256a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_PARAMETER); 12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Test if the socket is in an updated state */ 12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pLlcpSocket->eSocket_State != phFriNfc_LlcpTransportSocket_eSocketBound) 12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_INVALID_STATE); 12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pLlcpSocket->bSocketRecvPending) 12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_REJECTED); 12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phLibNfc_LlcpTransport_Connectionless_RecvFrom(pLlcpSocket, 12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psBuffer, 12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pRecv_Cb, 12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pContext); 12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1277a3af9c908f5c50e2405169015c86a1b667b42490Arnaud Ferir 12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1280