2 proto-t1.h: header file for proto-t1.c
3 Copyright (C) 2004 Ludovic Rousseau
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef __PROTO_T1_H__
21 #define __PROTO_T1_H__
30 /* T=1 protocol constants */
31 #define T1_I_BLOCK 0x00
32 #define T1_R_BLOCK 0x80
33 #define T1_S_BLOCK 0xC0
34 #define T1_MORE_BLOCKS 0x20
37 IFD_PROTOCOL_RECV_TIMEOUT = 0x0000,
38 IFD_PROTOCOL_T1_BLOCKSIZE,
39 IFD_PROTOCOL_T1_CHECKSUM_CRC,
40 IFD_PROTOCOL_T1_CHECKSUM_LRC,
43 IFD_PROTOCOL_T1_STATE,
47 #define T1_BUFFER_SIZE (3 + 254 + 2)
49 /* see /usr/include/PCSC/ifdhandler.h for other values
50 * this one is for internal use only */
51 #define IFD_PARITY_ERROR 699
57 unsigned char ns; /* reader side */
58 unsigned char nr; /* card side */
64 unsigned int rc_bytes;
66 unsigned int (*checksum)(const uint8_t *, size_t, unsigned char *);
68 char more; /* more data bit */
69 unsigned char previous_block[4]; /* to store the last R-block */
72 int t1_transceive(t1_state_t *t1, unsigned int dad,
73 const void *snd_buf, size_t snd_len,
74 void *rcv_buf, size_t rcv_len);
75 int t1_init(t1_state_t *t1, int lun);
76 void t1_release(t1_state_t *t1);
77 int t1_set_param(t1_state_t *t1, int type, long value);
78 int t1_negotiate_ifsd(t1_state_t *t1, unsigned int dad, int ifsd);
79 unsigned int t1_build(t1_state_t *, unsigned char *,
80 unsigned char, unsigned char, ct_buf_t *, size_t *);