File: structifd__driver__ops.html

package info (click to toggle)
openct 0.6.14-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,796 kB
  • ctags: 3,437
  • sloc: ansic: 19,575; sh: 9,107; makefile: 168
file content (473 lines) | stat: -rw-r--r-- 35,077 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>OpenCT: ifd_driver_ops Struct Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li id="current"><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="functions.html"><span>Data&nbsp;Fields</span></a></li>
  </ul></div>
<h1>ifd_driver_ops Struct Reference</h1><!-- doxytag: class="ifd_driver_ops" -->Driver operations.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="driver_8h-source.html">driver.h</a>&gt;</code>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="7fe78704cccb77cfb74b777ca715728d"></a><!-- doxytag: member="ifd_driver_ops::default_protocol" ref="7fe78704cccb77cfb74b777ca715728d" args="" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#7fe78704cccb77cfb74b777ca715728d">default_protocol</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#e7c3cc074db9e78318de2b3724e615b0">open</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, const char *name)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Open the reader.  <a href="#e7c3cc074db9e78318de2b3724e615b0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#0878891a6e17298e3e7e1410ee9745c9">close</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Close the reader.  <a href="#0878891a6e17298e3e7e1410ee9745c9"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#f2de522962059a3a56ab968027e91c24">change_parity</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int parity)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Change the communication protocol parity.  <a href="#f2de522962059a3a56ab968027e91c24"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#ef6ea1368322c8cfd288117d473d8c3a">change_speed</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int speed)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Change the communication protocol speed.  <a href="#ef6ea1368322c8cfd288117d473d8c3a"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#fd159b180342da11b01872f7cb0020bf">activate</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Activate the smart card reader.  <a href="#fd159b180342da11b01872f7cb0020bf"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#4fdec0e01964a5d4e1c46037088cf535">deactivate</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Deactivate the smart card reader.  <a href="#4fdec0e01964a5d4e1c46037088cf535"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#afa7094557da072235700f64923c72e1">card_status</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int *status)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Fetch the card status.  <a href="#afa7094557da072235700f64923c72e1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#712ea960720966070212c0721e0c48fc">card_reset</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, void *atr, size_t atr_len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Reset the card and fetch the ATR.  <a href="#712ea960720966070212c0721e0c48fc"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#0f225a09bb2372e3d6ce3a1d426fb43a">card_request</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, time_t timeout, const char *message, void *atr, size_t atr_len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Prompts the insertion of a smart card in the reader and performs a card reset.  <a href="#0f225a09bb2372e3d6ce3a1d426fb43a"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#aa13167aeabc61ed8af1d6ea58787dcd">card_eject</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, time_t timeout, const char *message)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Eject the smart card.  <a href="#aa13167aeabc61ed8af1d6ea58787dcd"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#38edbb0abab013180c965157d86e178f">output</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, const char *message)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Output a message on the reader's display.  <a href="#38edbb0abab013180c965157d86e178f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#2a89a4cd60cf1250550972b68997a097">perform_verify</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, unsigned int timeout, const char *prompt, const unsigned char *data, size_t data_len, unsigned char *resp, size_t resp_len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Request the PIN and have the card verify it.  <a href="#2a89a4cd60cf1250550972b68997a097"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#eff6dffc6f9ea7fe59a412b4a192f09d">send</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int dad, const unsigned char *buffer, size_t len)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send an APDU using the currently selected protocol.  <a href="#eff6dffc6f9ea7fe59a412b4a192f09d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#7b255459833f5882809694993f86a6c3">recv</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int dad, unsigned char *buffer, size_t len, long timeout)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Receive an APDU response using the currently selected protocol.  <a href="#7b255459833f5882809694993f86a6c3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#027a7ead30c7dfb7355119bf011b77cd">set_protocol</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int protocol)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Select the smart card communication protocol.  <a href="#027a7ead30c7dfb7355119bf011b77cd"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#5fa95fb08ef2d77bfacf0815a3e0e55d">transparent</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, const void *sbuf, size_t slen, void *rbuf, size_t rlen)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Transceive a protocol data unit.  <a href="#5fa95fb08ef2d77bfacf0815a3e0e55d"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#19af854b15071a7b68fc1552d63c35f5">sync_read</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int proto, unsigned short addr, unsigned char *rbuf, size_t rlen)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Read data from a synchronous smart card.  <a href="#19af854b15071a7b68fc1552d63c35f5"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structifd__driver__ops.html#718169f8db482fbaa7e993053ab1e370">sync_write</a> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int proto, unsigned short addr, const unsigned char *sbuf, size_t slen)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Write data to a synchronous smart card.  <a href="#718169f8db482fbaa7e993053ab1e370"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="655efbc5da06911914ad9920a75dd8f4"></a><!-- doxytag: member="ifd_driver_ops::escape" ref="655efbc5da06911914ad9920a75dd8f4" args=")(ifd_reader_t *reader, int slot, const void *sbuf, const size_t slen, void *rbuf, size_t rlen)" -->
int(*&nbsp;</td><td class="memItemRight" valign="bottom"><b>escape</b> )(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, const void *sbuf, const size_t slen, void *rbuf, size_t rlen)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Driver operations. 
<p>

<p>
Definition at line <a class="el" href="driver_8h-source.html#l00020">20</a> of file <a class="el" href="driver_8h-source.html">driver.h</a>.<hr><h2>Field Documentation</h2>
<a class="anchor" name="e7c3cc074db9e78318de2b3724e615b0"></a><!-- doxytag: member="ifd_driver_ops::open" ref="e7c3cc074db9e78318de2b3724e615b0" args=")(ifd_reader_t *reader, const char *name)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#e7c3cc074db9e78318de2b3724e615b0">open</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, const char *name)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Open the reader. 
<p>
This function opens the device named <em>name</em> and initialize the reader structure. The slots' dad should be set here.<p>
OpenCT calls the open function once at startup.<p>
Called by: ifd_open. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="0878891a6e17298e3e7e1410ee9745c9"></a><!-- doxytag: member="ifd_driver_ops::close" ref="0878891a6e17298e3e7e1410ee9745c9" args=")(ifd_reader_t *reader)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#0878891a6e17298e3e7e1410ee9745c9">close</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Close the reader. 
<p>
This function frees all the resources allocated by *open. If made possible by the hardware, the reader and all its slots must be powered off.<p>
The device will be closed by ifd_close, and must <b>not</b> be closed by this function.<p>
OpenCT currently never calls ifd_close, so the close function if not used.<p>
Called by: ifd_close. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="f2de522962059a3a56ab968027e91c24"></a><!-- doxytag: member="ifd_driver_ops::change_parity" ref="f2de522962059a3a56ab968027e91c24" args=")(ifd_reader_t *reader, int parity)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#f2de522962059a3a56ab968027e91c24">change_parity</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int parity)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Change the communication protocol parity. 
<p>
This function is only used for asynchronous smart cards with serial readers, and only if the reader doesn't auto-detect the protocol parity.<p>
Depending on the smart card communication protocol convention (either direct or inverse, see ISO-7816-3, 6.4), the communication between the reader and the smart card uses odd or even parity. If most readers handle smart card protocol convention transparently, the most simple ones map the smart card lines directly on the serial port or require the user to configure the reader according smart card communication protocol parity. For those readers, OpenCT will try both parities (starting with even) when reading the ATR.<p>
This function, if available, configures the reader and/or the serial port according to the smart card communication protocol parity. It is used by ifd_card_request only.<p>
Accepted values for <em>parity</em> are<p>
<ul>
<li><code>IFD_SERIAL_PARITY_ODD</code> (1) </li>
<li><code>IFD_SERIAL_PARITY_EVEN</code> (2)</li>
</ul>
Called by: ifd_card_request. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="ef6ea1368322c8cfd288117d473d8c3a"></a><!-- doxytag: member="ifd_driver_ops::change_speed" ref="ef6ea1368322c8cfd288117d473d8c3a" args=")(ifd_reader_t *reader, unsigned int speed)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#ef6ea1368322c8cfd288117d473d8c3a">change_speed</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int speed)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Change the communication protocol speed. 
<p>
It is not clear if this function was intended to change the communication speed between the host and the reader, the reader and the smart card, or both, as it is currently not used (ifd_set_speed is never called).<p>
Called by: ifd_set_speed. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="fd159b180342da11b01872f7cb0020bf"></a><!-- doxytag: member="ifd_driver_ops::activate" ref="fd159b180342da11b01872f7cb0020bf" args=")(ifd_reader_t *reader)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#fd159b180342da11b01872f7cb0020bf">activate</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Activate the smart card reader. 
<p>
This function performs all necessary operations to activate the smart card reader. After activation, the reader must be able to accept card status commands (card_status).<p>
Reader activation is currently performed once at startup, before calling card_status in response to CT_CMD_STATUS (is it really needed, as the reader was activated at startup ?), and when probing for synchronous cards.<p>
Called by: ifd_activate. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="4fdec0e01964a5d4e1c46037088cf535"></a><!-- doxytag: member="ifd_driver_ops::deactivate" ref="4fdec0e01964a5d4e1c46037088cf535" args=")(ifd_reader_t *reader)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#4fdec0e01964a5d4e1c46037088cf535">deactivate</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Deactivate the smart card reader. 
<p>
Reader deactivation is currently performed only when probing for synchronous cards. OpenCT deactivates and reactivates the reader before trying to access the card.<p>
Called by: ifd_deactivate. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="afa7094557da072235700f64923c72e1"></a><!-- doxytag: member="ifd_driver_ops::card_status" ref="afa7094557da072235700f64923c72e1" args=")(ifd_reader_t *reader, int slot, int *status)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#afa7094557da072235700f64923c72e1">card_status</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int *status)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Fetch the card status. 
<p>
This function returns the current card status for a given slot. status is a bitfield which currently accepts the following flags:<p>
<ul>
<li><code>IFD_CARD_PRESENT</code> (1) A card is present in the slot. </li>
<li><code>IFD_CARD_STATUS_CHANGED</code> (2) The slot status has changed since last call.</li>
</ul>
Beside using IFD_CARD_STATUS_CHANGED, OpenCT checks if the card status has changed by comparing the current status value with the previous status value. If the value of the IFD_CARD_PRESENT has changed, OpenCT will set the IFD_CARD_STATUS_CHANGED <b>on the client side</b>.<p>
On the server side, setting IFD_CARD_STATUS_CHANGED will also set atr_len to 0 for the given slot. As atr_len is only checked in ifd_protocol_select, and as that function is only called in ifd_card_request right after assigning a value to atr_len, this is currently pointless and a reader driver should <b>not</b> set IFD_CARD_STATUS_CHANGED if its only source of information is a change of the IFD_CARD_PRESENT flag between the current call and the previous one.<p>
Called by: ifd_card_status. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="712ea960720966070212c0721e0c48fc"></a><!-- doxytag: member="ifd_driver_ops::card_reset" ref="712ea960720966070212c0721e0c48fc" args=")(ifd_reader_t *reader, int slot, void *atr, size_t atr_len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#712ea960720966070212c0721e0c48fc">card_reset</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, void *atr, size_t atr_len)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Reset the card and fetch the ATR. 
<p>
This function resets the smart card and reads the Answer To Reset (ATR). The ATR will be stored in the slot structure by OpenCT, so the driver <b>must not</b> store the ATR itself in the slot structure.<p>
When resetting the card, the driver is allowed to select a protocol. If no protocol is selected when this function returns (assuming it returns successfully), OpenCT will try to select the protocol automatically (see set_protocol).<p>
Called by: ifd_card_request. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, length of the ATR if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="0f225a09bb2372e3d6ce3a1d426fb43a"></a><!-- doxytag: member="ifd_driver_ops::card_request" ref="0f225a09bb2372e3d6ce3a1d426fb43a" args=")(ifd_reader_t *reader, int slot, time_t timeout, const char *message, void *atr, size_t atr_len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#0f225a09bb2372e3d6ce3a1d426fb43a">card_request</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, time_t timeout, const char *message, void *atr, size_t atr_len)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Prompts the insertion of a smart card in the reader and performs a card reset. 
<p>
This function prompts the user to insert a smart card in the reader. For card readers equipped with a display, the optional message message should be displayed to the user. The optional parameter timeout, if not equal to zero, gives the prompt timeout in seconds.<p>
If a card is inserted before the timeout elapses, the card is reset and the ATR is fetched. See card_reset for more information.<p>
Called by: ifd_card_request <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, length of the ATR if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="aa13167aeabc61ed8af1d6ea58787dcd"></a><!-- doxytag: member="ifd_driver_ops::card_eject" ref="aa13167aeabc61ed8af1d6ea58787dcd" args=")(ifd_reader_t *reader, int slot, time_t timeout, const char *message)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#aa13167aeabc61ed8af1d6ea58787dcd">card_eject</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, time_t timeout, const char *message)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Eject the smart card. 
<p>
This function ejects the smart card or prompt the user to remove the card by displaying the message <em>message</em>. The optional parameter <em>timeout</em>, if not equal to zero, gives the card removal timeout in seconds.<p>
It is not clear if this function should deactivate the smart card first, or if the caller must deactivate the card before calling card_eject.<p>
Called by: ifd_card_eject. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="38edbb0abab013180c965157d86e178f"></a><!-- doxytag: member="ifd_driver_ops::output" ref="38edbb0abab013180c965157d86e178f" args=")(ifd_reader_t *reader, const char *message)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#38edbb0abab013180c965157d86e178f">output</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, const char *message)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Output a message on the reader's display. 
<p>
Called by: ifd_output. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="2a89a4cd60cf1250550972b68997a097"></a><!-- doxytag: member="ifd_driver_ops::perform_verify" ref="2a89a4cd60cf1250550972b68997a097" args=")(ifd_reader_t *reader, int slot, unsigned int timeout, const char *prompt, const unsigned char *data, size_t data_len, unsigned char *resp, size_t resp_len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#2a89a4cd60cf1250550972b68997a097">perform_verify</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, unsigned int timeout, const char *prompt, const unsigned char *data, size_t data_len, unsigned char *resp, size_t resp_len)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Request the PIN and have the card verify it. 
<p>
This function prompts the user to enter his PIN code and have the smart card verify the code. The optional parameter <em>timeout</em>, if not equal to zero, gives the PIN request timeout.<p>
The two bytes status (SW1-SW2) is copied in the <em>resp</em> buffer. If the status indicates a known error (IFD_ERROR_USER_TIMEOUT, IFD_ERROR_USER_ABORT, IFD_ERROR_PIN_MISMATCH) the error code is returned. Otherwise the length of the response (2) is returned.<p>
Called by: ifd_perform_verify. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, size of the response (2) if success or unknown error. </dd></dl>

</div>
</div><p>
<a class="anchor" name="eff6dffc6f9ea7fe59a412b4a192f09d"></a><!-- doxytag: member="ifd_driver_ops::send" ref="eff6dffc6f9ea7fe59a412b4a192f09d" args=")(ifd_reader_t *reader, unsigned int dad, const unsigned char *buffer, size_t len)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#eff6dffc6f9ea7fe59a412b4a192f09d">send</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int dad, const unsigned char *buffer, size_t len)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Send an APDU using the currently selected protocol. 
<p>
This function is called by all non-transparent protocols to send an APDU to a device. The device address is set by the <em>dad</em> parameter which is one of<p>
<ul>
<li><code>IFD_DAD_HOST</code> (0) Host (PC) - what's the point ? </li>
<li><code>IFD_DAD_IFD</code> (1) The APDU is sent to the reader </li>
<li><code>IFD_DAD_ICC1</code> (2) The APDU is sent to the first smart card </li>
<li><code>IFD_DAD_ICC2</code> (3) The APDU is sent to the second smart card</li>
</ul>
The <em>dad</em> parameter is currently unused by all drivers, even the Kaan driver which takes care to initialize it correctly in the open function.<p>
Called by: ifd_send_command. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, number of bytes sent if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="7b255459833f5882809694993f86a6c3"></a><!-- doxytag: member="ifd_driver_ops::recv" ref="7b255459833f5882809694993f86a6c3" args=")(ifd_reader_t *reader, unsigned int dad, unsigned char *buffer, size_t len, long timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#7b255459833f5882809694993f86a6c3">recv</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, unsigned int dad, unsigned char *buffer, size_t len, long timeout)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Receive an APDU response using the currently selected protocol. 
<p>
This function is called by all non-transparent protocols to receive an APDU response from a device. The device address is set by the <em>dad</em> parameter which takes the same values as for the send function.<p>
The <em>dad</em> parameter is currently unused by all drivers, even the Kaan driver which takes care to initialize it correctly in the open function.<p>
Called by: ifd_recv_response. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, number of bytes received if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="027a7ead30c7dfb7355119bf011b77cd"></a><!-- doxytag: member="ifd_driver_ops::set_protocol" ref="027a7ead30c7dfb7355119bf011b77cd" args=")(ifd_reader_t *reader, int slot, int protocol)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#027a7ead30c7dfb7355119bf011b77cd">set_protocol</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int protocol)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Select the smart card communication protocol. 
<p>
The smart card communication protocol is selected by OpenCT when the card is reset (either by reset_card or request_card), and can be overriden by the user by sending a CT_CMD_SET_PROTOCOL command.<p>
OpenCT doesn't perform a PPS exchange with the card itself, but selects the first protocol offered by the ATR at reset time by calling set_protocol. If the reader performs the PPS exchange with the card, the selected protocol can be set manually by the driver (by setting slot-&gt;proto) and set_protocol will not be called.<p>
It is not clear what the side effects of CT_CMD_SET_PROTOCOL (should it reset the card ?) should be and if that function is used at all by applications. Isn't the default protocol good enough ? I would have thought that set_protocol was meant to be called only right after reset, to select the protocol and instruct the driver to perform a PPS exchange.<p>
Called by: ifd_set_protocol, ifd_select_protocol. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure. </dd></dl>

</div>
</div><p>
<a class="anchor" name="5fa95fb08ef2d77bfacf0815a3e0e55d"></a><!-- doxytag: member="ifd_driver_ops::transparent" ref="5fa95fb08ef2d77bfacf0815a3e0e55d" args=")(ifd_reader_t *reader, int slot, const void *sbuf, size_t slen, void *rbuf, size_t rlen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#5fa95fb08ef2d77bfacf0815a3e0e55d">transparent</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, const void *sbuf, size_t slen, void *rbuf, size_t rlen)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Transceive a protocol data unit. 
<p>
This function is used by the transparent protocol, when the driver and/or the reader accepts raw PDUs directly. When using the transparent protocol, the PDUs sent by the client are forwarded directly to the driver without being mangled by OpenCT. If the driver and/or the reader can't accept the PDUs directly (for instance when the reader doesn't support Case 4 APDUs in T=0 protocol), the driver should instanciate the appropriate protocol handler to pre-process the PDUs. In that case, the send and recv functions will be used instead of the transparent function.<p>
Called by: trans_transceive at proto-trans.c <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, size of the response if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="19af854b15071a7b68fc1552d63c35f5"></a><!-- doxytag: member="ifd_driver_ops::sync_read" ref="19af854b15071a7b68fc1552d63c35f5" args=")(ifd_reader_t *reader, int slot, int proto, unsigned short addr, unsigned char *rbuf, size_t rlen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#19af854b15071a7b68fc1552d63c35f5">sync_read</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int proto, unsigned short addr, unsigned char *rbuf, size_t rlen)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read data from a synchronous smart card. 
<p>
This function writes <em>rlen</em> bytes to the smart card, starting at address <em>addr</em>. The <em>proto</em> parameter specifies the desired communication protocol. The driver must set the protocol before reading data, or return an error if the protocol is not supported.<p>
Called by: sync_read at proto-sync.c, sync_write at proto-sync.c. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, number of bytes read if success. </dd></dl>

</div>
</div><p>
<a class="anchor" name="718169f8db482fbaa7e993053ab1e370"></a><!-- doxytag: member="ifd_driver_ops::sync_write" ref="718169f8db482fbaa7e993053ab1e370" args=")(ifd_reader_t *reader, int slot, int proto, unsigned short addr, const unsigned char *sbuf, size_t slen)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* <a class="el" href="structifd__driver__ops.html#718169f8db482fbaa7e993053ab1e370">sync_write</a>)(<a class="el" href="structifd__reader.html">ifd_reader_t</a> *reader, int slot, int proto, unsigned short addr, const unsigned char *sbuf, size_t slen)          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Write data to a synchronous smart card. 
<p>
This function reads <em>slen</em> bytes from the smart card, starting at address <em>addr</em>. The <em>proto</em> parameter specifies the desired communication protocol. The driver must set the protocol before writing data, or return an error if the protocol is not supported.<p>
Called by: sync_write at proto-sync.c. <dl class="return" compact><dt><b>Returns:</b></dt><dd>Error code &lt;0 if failure, number of bytes written if success. </dd></dl>

</div>
</div><p>
<hr>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="driver_8h-source.html">driver.h</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Thu Aug 30 20:21:19 2007 for OpenCT by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>