/* ****************************************************************************** * INTERPEAK INTERNAL API HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipeap_sim_reader.h,v $ $Revision: 1.3 $ * $Source: /home/interpeak/CVSRoot/ipeap/src/ipeap_sim_reader.h,v $ * $Author: dbush $ $Date: 2008-04-06 21:35:02 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Roger Boden ****************************************************************************** */ #if !defined(IPEAP_SIM_READER_H) && \ (defined(IPEAP_USE_EAP_SIM) || defined(IPEAP_USE_EAP_AKA)) #define IPEAP_SIM_READER_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipeap_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #include #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #ifndef SCARD_S_SUCCESS #define SCARD_S_SUCCESS 0x00000000 #define SCARD_E_CANCELLED 0x80100002 #define SCARD_E_CANT_DISPOSE 0x8010000E #define SCARD_E_INSUFFICIENT_BUFFER 0x80100008 #define SCARD_E_INVALID_ATR 0x80100015 #define SCARD_E_INVALID_HANDLE 0x80100003 #define SCARD_E_INVALID_PARAMETER 0x80100004 #define SCARD_E_INVALID_TARGET 0x80100005 #define SCARD_E_INVALID_VALUE 0x80100011 #define SCARD_E_NO_MEMORY 0x80100006 #define SCARD_F_COMM_ERROR 0x80100013 #define SCARD_F_INTERNAL_ERROR 0x80100001 #define SCARD_F_UNKNOWN_ERROR 0x80100014 #define SCARD_F_WAITED_TOO_LONG 0x80100007 #define SCARD_E_UNKNOWN_READER 0x80100009 #define SCARD_E_TIMEOUT 0x8010000A #define SCARD_E_SHARING_VIOLATION 0x8010000B #define SCARD_E_NO_SMARTCARD 0x8010000C #define SCARD_E_UNKNOWN_CARD 0x8010000D #define SCARD_E_PROTO_MISMATCH 0x8010000F #define SCARD_E_NOT_READY 0x80100010 #define SCARD_E_SYSTEM_CANCELLED 0x80100012 #define SCARD_E_NOT_TRANSACTED 0x80100016 #define SCARD_E_READER_UNAVAILABLE 0x80100017 #define SCARD_W_UNSUPPORTED_CARD 0x80100065 #define SCARD_W_UNRESPONSIVE_CARD 0x80100066 #define SCARD_W_UNPOWERED_CARD 0x80100067 #define SCARD_W_RESET_CARD 0x80100068 #define SCARD_W_REMOVED_CARD 0x80100069 #define SCARD_W_INSERTED_CARD 0x8010006A #define SCARD_E_UNSUPPORTED_FEATURE 0x8010001F #define SCARD_E_PCI_TOO_SMALL 0x80100019 #define SCARD_E_READER_UNSUPPORTED 0x8010001A #define SCARD_E_DUPLICATE_READER 0x8010001B #define SCARD_E_CARD_UNSUPPORTED 0x8010001C #define SCARD_E_NO_SERVICE 0x8010001D #define SCARD_E_SERVICE_STOPPED 0x8010001E #endif #ifndef SCARD_SCOPE_USER #define SCARD_SCOPE_USER 0x0000 /* Scope in user space */ #define SCARD_SCOPE_TERMINAL 0x0001 /* Scope in terminal */ #define SCARD_SCOPE_SYSTEM 0x0002 /* Scope in system */ #define SCARD_SCOPE_GLOBAL 0x0003 /* Scope is global */ #endif #ifndef SCARD_PROTOCOL_T0 #define SCARD_PROTOCOL_T0 0x0001 /* T=0 active protocol. */ #define SCARD_PROTOCOL_T1 0x0002 /* T=1 active protocol. */ #endif #ifndef SCARD_SHARE_EXCLUSIVE #define SCARD_SHARE_EXCLUSIVE 0x0001 /* Exclusive mode only */ #define SCARD_SHARE_SHARED 0x0002 /* Shared mode only */ #define SCARD_SHARE_DIRECT 0x0003 /* Raw mode only */ #endif #ifndef SCARD_LEAVE_CARD #define SCARD_LEAVE_CARD 0x0000 /* Do nothing on close */ #define SCARD_RESET_CARD 0x0001 /* Reset on close */ #define SCARD_UNPOWER_CARD 0x0002 /* Power down on close */ #define SCARD_EJECT_CARD 0x0003 /* Eject on close */ #endif /* **************************************************************************** * 5 TYPES **************************************************************************** */ #ifndef SCARDCONTEXT typedef Ip_u32 SCARDCONTEXT; typedef SCARDCONTEXT *PSCARDCONTEXT, *LPSCARDCONTEXT; #endif #ifndef SCARDHANDLE typedef Ip_u32 SCARDHANDLE; typedef SCARDHANDLE *PSCARDHANDLE, *LPSCARDHANDLE; #endif typedef struct { Ip_u32 dwProtocol; /* Protocol identifier */ Ip_u32 cbPciLength; /* Protocol Control Information Length */ } CARD_IO_REQUEST, *LPCARD_IO_REQUEST; typedef const CARD_IO_REQUEST *LPCCARD_IO_REQUEST; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ /* *=========================================================================== * ipeap_reader_establish_context *=========================================================================== * Description: Establish a connection with PC/SC. * Parameters: dwScope - Scope of connection * pvReserved1 - Must be set to IP_NULL * pvReserved2 - Must be set to IP_NULL * phContext - Will get handle to contect if succesful. * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_establish_context( Ip_u32 dwScope, const void* pvReserved1, const void* pvReserved2, LPSCARDCONTEXT phContext); /* *=========================================================================== * ipeap_reader_release_context *=========================================================================== * Description: Release a connection with PC/SC. * Parameters: hContext - Handle to existing context. * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_release_context( SCARDCONTEXT hContext); /* *=========================================================================== * ipeap_reader_list_readers *=========================================================================== * Description: List available PC/SC readers. Will return a list of strings * separated with 0. The last string will end with two 0. May * ask for length of needed buffer: set mszReaders to IP_NULL. * Parameters: hContext - Handle to existing context. * mszGroups - Reader group. * mszReaders - Buffer for reader strings. * pcchReaders - Length of reader strings buffer. * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_list_readers( SCARDCONTEXT hContext, const char* mszGroups, char* mszReaders, Ip_u32* pcchReaders); /* *=========================================================================== * ipeap_reader_connect *=========================================================================== * Description: Open a connection with a card in a PC/SC reader. * Parameters: hContext - Handle to existing context. * szReader - The reader name to connect. * dwShareMode - Share mode for the connection. * dwPreferredProtocols - Prefered protocol used for the * connection. * phCard - Will receive a handle to the card if successful. * pdwActiveProtocol - Will receive the protocol used if * successful. * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_connect( SCARDCONTEXT hContext, const char* szReader, Ip_u32 dwShareMode, Ip_u32 dwPreferredProtocols, LPSCARDHANDLE phCard, Ip_u32* pdwActiveProtocol); /* *=========================================================================== * ipeap_reader_disconnect *=========================================================================== * Description: Close a connection with a card in a PC/SC reader. * Parameters: hCard - Handle to card context. * dwDisposition - How should the connection be closed. * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_disconnect( SCARDHANDLE hCard, Ip_u32 dwDisposition); /* *=========================================================================== * ipeap_reader_transmit *=========================================================================== * Description: Transmit a command towards a card in a PC/SC reader. * Parameters: hCard - Handle to card context. * pioSendPci - Send protocol control information * pbSendBuffer - Send command buffer * cbSendLength - Send command buffer length * pioRecvPci - Receive protocol control information * pbRecvBuffer - Receive command buffer * pcbRecvLength - Receive command buffer length * Returns: PC/SC error code */ IP_GLOBAL Ip_u32 ipeap_reader_transmit( SCARDHANDLE hCard, LPCCARD_IO_REQUEST pioSendPci, const Ip_u8* pbSendBuffer, Ip_u32 cbSendLength, LPCARD_IO_REQUEST pioRecvPci, Ip_u8* pbRecvBuffer, Ip_u32* pcbRecvLength); #endif /* **************************************************************************** * END OF FILE **************************************************************************** */