Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

LONG IFDTransmit ( PREADER_CONTEXT  rContext,
SCARD_IO_HEADER  pioTxPci,
PUCHAR  pucTxBuffer,
DWORD  dwTxLength,
PUCHAR  pucRxBuffer,
PDWORD  pdwRxLength,
PSCARD_IO_HEADER  pioRxPci 
)

Transmit an APDU to the ICC.

Definition at line 657 of file ifdwrapper.c.

References IFDSetCapabilities(), SCARD_E_NOT_TRANSACTED, SCARD_E_READER_UNAVAILABLE, and SCARD_S_SUCCESS.

Referenced by SCardTransmit().

{
      RESPONSECODE rv = IFD_SUCCESS;
      UCHAR ucValue[1] = "\x00";

#ifndef PCSCLITE_STATIC_DRIVER
      RESPONSECODE(*IFD_transmit_to_icc) (SCARD_IO_HEADER, PUCHAR, DWORD,
            /*@out@*/ PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
      RESPONSECODE(*IFDH_transmit_to_icc) (DWORD, SCARD_IO_HEADER, PUCHAR,
            DWORD, /*@out@*/ PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
#endif

      /* log the APDU */
      DebugLogCategory(DEBUG_CATEGORY_APDU, pucTxBuffer, dwTxLength);

#ifndef PCSCLITE_STATIC_DRIVER
      if (rContext->dwVersion == IFD_HVERSION_1_0)
            IFD_transmit_to_icc =
                  rContext->psFunctions.psFunctions_v1.pvfTransmitToICC;
      else
            IFDH_transmit_to_icc =
                  rContext->psFunctions.psFunctions_v2.pvfTransmitToICC;
#endif

      /* LOCK THIS CODE REGION */ 
      (void)SYS_MutexLock(rContext->mMutex);

#ifndef PCSCLITE_STATIC_DRIVER
      if (rContext->dwVersion == IFD_HVERSION_1_0)
      {
            ucValue[0] = rContext->dwSlot;
            (void)IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
            rv = (*IFD_transmit_to_icc) (pioTxPci, (LPBYTE) pucTxBuffer,
                  dwTxLength, pucRxBuffer, pdwRxLength, pioRxPci);
      }
      else
            rv = (*IFDH_transmit_to_icc) (rContext->dwSlot, pioTxPci,
                  (LPBYTE) pucTxBuffer, dwTxLength,
                  pucRxBuffer, pdwRxLength, pioRxPci);
#else
      if (rContext->dwVersion == IFD_HVERSION_1_0)
      {
            ucValue[0] = rContext->dwSlot;
            (void)IFDSetCapabilities(rContext, TAG_IFD_SLOTNUM, 1, ucValue);
            rv = IFD_Transmit_to_ICC(pioTxPci, (LPBYTE) pucTxBuffer,
                  dwTxLength, pucRxBuffer, pdwRxLength, pioRxPci);
      }
      else
            rv = IFDHTransmitToICC(rContext->dwSlot, pioTxPci,
                  (LPBYTE) pucTxBuffer, dwTxLength,
                  pucRxBuffer, pdwRxLength, pioRxPci);
#endif

      /* END OF LOCKED REGION */
      (void)SYS_MutexUnLock(rContext->mMutex);

      /* log the returned status word */
      DebugLogCategory(DEBUG_CATEGORY_SW, pucRxBuffer, *pdwRxLength);

      if (rv == IFD_SUCCESS)
            return SCARD_S_SUCCESS;
      else
      {
            Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);

            if (rv == IFD_NO_SUCH_DEVICE)
            {
                  (void)SendHotplugSignal();
                  return SCARD_E_READER_UNAVAILABLE;
            }

            return SCARD_E_NOT_TRANSACTED;
      }
}


Generated by  Doxygen 1.6.0   Back to index