/[pcsclite]/trunk/Drivers/ccid/src/ccid.c
ViewVC logotype

Contents of /trunk/Drivers/ccid/src/ccid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 611 - (show annotations) (download)
Thu Jan 15 13:41:01 2004 UTC (9 years, 5 months ago) by rousseau
File MIME type: text/plain
File size: 3554 byte(s)
use an (int *) instead of a PDWORD for rx_length argument
1 /*
2 ccid.c: CCID common code
3 Copyright (C) 2003 Ludovic Rousseau
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 /*
21 * $Id$
22 */
23
24 #include "config.h"
25 #include "debug.h"
26 #include "pcscdefines.h"
27 #include "defs.h"
28 #include "ifdhandler.h"
29 #include "ccid.h"
30 #include "commands.h"
31
32 /*****************************************************************************
33 *
34 * ccid_open_hack
35 *
36 ****************************************************************************/
37 int ccid_open_hack(int lun)
38 {
39 _ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
40
41 switch (ccid_descriptor->readerID)
42 {
43 case CARDMAN3121+1:
44 /* Reader announces APDU but is in fact TPDU */
45 ccid_descriptor->dwFeatures &= ~CCID_CLASS_EXCHANGE_MASK;
46 ccid_descriptor->dwFeatures |= CCID_CLASS_TPDU;
47 break;
48
49 #if 0
50 /*
51 * Do not switch to APDU mode since it also swicth in EMV mode and
52 * may not work with non EMV cards
53 */
54 case GEMPCKEY:
55 case GEMPCTWIN:
56 /* Reader announces TPDU but can do APDU */
57 if (CmdEscape(lun, ESC_GEMPC_SET_APDU_MODE) == IFD_SUCCESS)
58 {
59 ccid_descriptor->dwFeatures &= ~CCID_CLASS_EXCHANGE_MASK;
60 ccid_descriptor->dwFeatures |= CCID_CLASS_SHORT_APDU;
61 }
62 break;
63 #endif
64 }
65
66 return 0;
67 } /* ccid_open_hack */
68
69 /*****************************************************************************
70 *
71 * ccid_error
72 *
73 ****************************************************************************/
74 void ccid_error(int error, char *file, int line)
75 {
76 char *text;
77
78 switch (error)
79 {
80 case 0x00:
81 text = "Command not supported or not allowed";
82 break;
83
84 case 0x01:
85 text = "Wrong command length";
86 break;
87
88 case 0x02:
89 text = "Reader detects an excessive current. Card powered off";
90 break;
91
92 case 0x03:
93 text = "Reader detects a defective voltage. Card powered off";
94 break;
95
96 case 0x05:
97 text = "Slot number is invalid (it must be set to 0)";
98 break;
99
100 case 0x07:
101 case 0x08:
102 case 0x09:
103 case 0x0A:
104 case 0x15:
105 text = "Byte displayed is invalid";
106 break;
107
108 case 0xA2:
109 text = "Card short-circuiting. Card powered off";
110 break;
111
112 case 0xA3:
113 text = "ATR too long (> 33)";
114 break;
115
116 case 0xB0:
117 text = "Reader in EMV mode and T=1 message too long";
118 break;
119
120 case 0xBB:
121 text = "Protocol error in EMV mode";
122 break;
123
124 case 0xBD:
125 text = "Card error during T=1 exchange";
126 break;
127
128 case 0xBE:
129 text = "Wrong APDU command length";
130 break;
131
132 case 0xF4:
133 text = "Procedure byte conflict";
134 break;
135
136 case 0xF7:
137 text = "Invalid ATR checksum byte (TCK)";
138 break;
139
140 case 0xF8:
141 text = "Invalid ATR first byte";
142 break;
143
144 case 0xFD:
145 text = "Parity error during exchange";
146 break;
147
148 case 0xFE:
149 text = "Card absent or mute";
150 break;
151
152 default:
153 text = "Unknown CCID error";
154 break;
155
156 }
157 debug_msg("%s:%d %s", file, line, text);
158
159 } /* ccid_error */
160

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5