Changeset 959 for trunk/src/ifd
- Timestamp:
- 05/25/07 19:53:49 (5 years ago)
- Location:
- trunk/src/ifd
- Files:
-
- 4 edited
-
Makefile.am (modified) (1 diff)
-
ifd-ccid.c (modified) (10 diffs)
-
init.c (modified) (1 diff)
-
internal.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ifd/Makefile.am
r832 r959 21 21 \ 22 22 proto-gbp.c proto-sync.c proto-t0.c proto-t1.c \ 23 proto-trans.c \23 proto-trans.c proto-escape.c \ 24 24 \ 25 25 sys-sunray.c sys-solaris.c sys-bsd.c sys-linux.c sys-null.c sys-osx.c \ -
trunk/src/ifd/ifd-ccid.c
r953 r959 6 6 * 2005-04-20: Harald Welte <laforge@gnumonks.org> 7 7 * Add support for PCMCIA based CCID Device (CardMan 4040) 8 * 9 * 2005-05-22: Harald Welte <laforge@gnumonks.org> 10 * Add suport for OmniKey Cardman 5121 RFID extensions 8 11 */ 9 12 … … 123 126 #define SUPPORT_T0 0x1 124 127 #define SUPPORT_T1 0x2 128 #define SUPPORT_ESCAPE 0x80 125 129 126 130 #define SUPPORT_50V 1 … … 741 745 } 742 746 747 if (de.idVendor == 0x076b && de.idProduct == 0x5121) { 748 /* special handling of RFID part of OmniKey 5121 */ 749 reader->nslots++; /* one virtual slot for RFID escape */ 750 st->proto_support |= SUPPORT_ESCAPE; 751 } 752 743 753 return 0; 744 754 } … … 816 826 int any = 0; 817 827 int i, j, bits; 828 829 if (st->proto_support & SUPPORT_ESCAPE 830 && slot == reader->nslots-1) { 831 ifd_debug(1, "virtual escape slot, setting card present\n"); 832 *status = IFD_CARD_PRESENT; 833 return 0; 834 } 818 835 819 836 i = 1 + (slot / 4); … … 881 898 } 882 899 900 static int ccid_set_protocol(ifd_reader_t *reader, int s, int proto); 901 883 902 /* 884 903 * Reset … … 899 918 return IFD_ERROR_NO_CARD; 900 919 920 if (st->proto_support & SUPPORT_ESCAPE 921 && slot == reader->nslots-1) { 922 ifd_debug(1, "slot: %d, setting atr to 0xff", slot); 923 *((char *)atr) = 0xff; 924 ccid_set_protocol(reader, slot, IFD_PROTOCOL_ESCAPE); 925 return 1; 926 } 901 927 memset(ctlbuf, 0, 3); 902 928 … … 941 967 int r; 942 968 969 slot = &reader->slot[s]; 970 971 /* If we support RFID escaping, we only allow ESCAPE protocol 972 * at the last (== virtual) slot */ 973 if ((st->proto_support & SUPPORT_ESCAPE) 974 && (proto != IFD_PROTOCOL_ESCAPE) 975 && (s == reader->nslots-1)) { 976 ct_error("reader doesn't support this protocol at this slot\n"); 977 return IFD_ERROR_NOT_SUPPORTED; 978 } 979 943 980 switch (proto) { 944 981 case IFD_PROTOCOL_T0: … … 954 991 } 955 992 break; 993 case IFD_PROTOCOL_ESCAPE: 994 /* virtual "escape" fallthrough protocol for stacking RFID 995 * protocol stack on top of openct */ 996 if (!(st->proto_support & SUPPORT_ESCAPE)) { 997 ct_error("reader does not support this protocol"); 998 return IFD_ERROR_NOT_SUPPORTED; 999 } 1000 if (s != reader->nslots-1) { 1001 ct_error("reader doesn't support this protocol at this slot"); 1002 return IFD_ERROR_NOT_SUPPORTED; 1003 } 1004 p = ifd_protocol_new(IFD_PROTOCOL_ESCAPE,reader, slot->dad); 1005 if (!p) { 1006 ct_error("%s: internal error", reader->name); 1007 return -1; 1008 } 1009 if (slot->proto) { 1010 ifd_protocol_free(slot->proto); 1011 slot->proto = NULL; 1012 } 1013 slot->proto = p; 1014 st->icc_proto[s] = proto; 1015 ifd_debug(1, "set protocol to ESCAPE\n"); 1016 return 0; 1017 break; 956 1018 default: 957 1019 ct_error("protocol unknown"); 958 1020 return IFD_ERROR_NOT_SUPPORTED; 959 1021 } 960 961 slot = &reader->slot[s];962 1022 963 1023 if (st->reader_type == TYPE_APDU) { … … 1104 1164 } 1105 1165 1166 static int ccid_escape(ifd_reader_t *reader, int slot, void *sbuf, 1167 size_t slen, void *rbuf, size_t rlen) 1168 { 1169 unsigned char sendbuf[CCID_MAX_MSG_LEN]; 1170 unsigned char recvbuf[CCID_MAX_MSG_LEN]; 1171 int r; 1172 1173 ifd_debug(1, "slot: %d, slen %d, rlen %d", slot, slen, rlen); 1174 1175 r = ccid_prepare_cmd(reader, sendbuf, sizeof(sendbuf), slot, 1176 CCID_CMD_ESCAPE, NULL, sbuf, slen); 1177 if (r < 0) 1178 return r; 1179 1180 r = ccid_command(reader, &sendbuf[0], r, recvbuf, sizeof(recvbuf)); 1181 if (r < 0) 1182 return r; 1183 1184 return ccid_extract_data(&recvbuf, r, rbuf, rlen); 1185 } 1186 1106 1187 static int 1107 1188 ccid_transparent(ifd_reader_t * reader, int slot, … … 1178 1259 ccid_driver.send = ccid_send; 1179 1260 ccid_driver.recv = ccid_recv; 1261 ccid_driver.escape = ccid_escape; 1180 1262 1181 1263 ifd_driver_register("ccid", &ccid_driver); -
trunk/src/ifd/init.c
r948 r959 55 55 ifd_protocol_register(&ifd_protocol_3wire); 56 56 ifd_protocol_register(&ifd_protocol_eurochip); 57 ifd_protocol_register(&ifd_protocol_esc); 57 58 58 59 if (ifd_conf_get_integer("debug", &ival) >= 0 && ival > ct_config.debug) -
trunk/src/ifd/internal.h
r909 r959 114 114 extern struct ifd_protocol_ops ifd_protocol_3wire; 115 115 extern struct ifd_protocol_ops ifd_protocol_eurochip; 116 extern struct ifd_protocol_ops ifd_protocol_esc; 116 117 117 118 extern void ifd_acr30u_register(void);
Note: See TracChangeset
for help on using the changeset viewer.
