Changeset 959 for trunk/src/ifd


Ignore:
Timestamp:
05/25/07 19:53:49 (5 years ago)
Author:
aj
Message:

add patch by Harald Welte for contactless reader support.

Location:
trunk/src/ifd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ifd/Makefile.am

    r832 r959  
    2121        \ 
    2222        proto-gbp.c proto-sync.c proto-t0.c proto-t1.c \ 
    23         proto-trans.c \ 
     23        proto-trans.c proto-escape.c \ 
    2424        \ 
    2525        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  
    66 * 2005-04-20: Harald Welte <laforge@gnumonks.org> 
    77 *      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 
    811 */ 
    912 
     
    123126#define SUPPORT_T0      0x1 
    124127#define SUPPORT_T1      0x2 
     128#define SUPPORT_ESCAPE  0x80 
    125129 
    126130#define SUPPORT_50V     1 
     
    741745        } 
    742746 
     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 
    743753        return 0; 
    744754} 
     
    816826                int any = 0; 
    817827                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                } 
    818835 
    819836                i = 1 + (slot / 4); 
     
    881898} 
    882899 
     900static int ccid_set_protocol(ifd_reader_t *reader, int s, int proto); 
     901 
    883902/* 
    884903 * Reset 
     
    899918                return IFD_ERROR_NO_CARD; 
    900919 
     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        } 
    901927        memset(ctlbuf, 0, 3); 
    902928 
     
    941967        int r; 
    942968 
     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 
    943980        switch (proto) { 
    944981        case IFD_PROTOCOL_T0: 
     
    954991                } 
    955992                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; 
    9561018        default: 
    9571019                ct_error("protocol unknown"); 
    9581020                return IFD_ERROR_NOT_SUPPORTED; 
    9591021        } 
    960  
    961         slot = &reader->slot[s]; 
    9621022 
    9631023        if (st->reader_type == TYPE_APDU) { 
     
    11041164} 
    11051165 
     1166static 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 
    11061187static int 
    11071188ccid_transparent(ifd_reader_t * reader, int slot, 
     
    11781259        ccid_driver.send = ccid_send; 
    11791260        ccid_driver.recv = ccid_recv; 
     1261        ccid_driver.escape = ccid_escape; 
    11801262 
    11811263        ifd_driver_register("ccid", &ccid_driver); 
  • trunk/src/ifd/init.c

    r948 r959  
    5555        ifd_protocol_register(&ifd_protocol_3wire); 
    5656        ifd_protocol_register(&ifd_protocol_eurochip); 
     57        ifd_protocol_register(&ifd_protocol_esc); 
    5758 
    5859        if (ifd_conf_get_integer("debug", &ival) >= 0 && ival > ct_config.debug) 
  • trunk/src/ifd/internal.h

    r909 r959  
    114114extern struct ifd_protocol_ops ifd_protocol_3wire; 
    115115extern struct ifd_protocol_ops ifd_protocol_eurochip; 
     116extern struct ifd_protocol_ops ifd_protocol_esc; 
    116117 
    117118extern void ifd_acr30u_register(void); 
Note: See TracChangeset for help on using the changeset viewer.