Hi.

some fixes and changes by olaf kirch.
david, please apply.

(btw: where is the current cvs tree? is it still this ?)
[EMAIL PROTECTED]:/cvsroot/muscleframework

regards, andreas

Index: ETokenDriver//COPYRIGHT
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/COPYRIGHT,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 COPYRIGHT
--- ETokenDriver//COPYRIGHT     17 Mar 2002 18:04:55 -0000      1.1.1.1
+++ ETokenDriver//COPYRIGHT     13 Jun 2002 16:55:38 -0000
@@ -1,4 +1,5 @@
 (C) 2002 by Andreas Jellinghaus <[EMAIL PROTECTED]>
+(C) 2002 by Olaf Kirch <[EMAIL PROTECTED]>
 
 the t1 implementation is based on scez - smartcard library
 (C) 1999 - 2002 by Matthias Bruestle <[EMAIL PROTECTED]>
Index: ETokenDriver//README
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/README,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 README
--- ETokenDriver//README        17 Mar 2002 18:04:56 -0000      1.1.1.1
+++ ETokenDriver//README        13 Jun 2002 16:55:38 -0000
@@ -27,6 +27,11 @@
 
 it works a bit.
 
+13.6.2002      verson 0.3 released
+debugging now via syslog
+fix in t=1
+both done by olaf kirch, thanks!
+
 8.2.2002       version 0.2 release
 fixed very nasty bug in t1 protocol
 
Index: ETokenDriver//etoken.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/etoken.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 etoken.c
--- ETokenDriver//etoken.c      17 Mar 2002 18:04:56 -0000      1.1.1.1
+++ ETokenDriver//etoken.c      13 Jun 2002 16:55:39 -0000
@@ -4,6 +4,7 @@
 #include <usb.h>
 #include <stdio.h>
 #include <sys/types.h>
+#include <syslog.h>
 
 #include "etoken.h"
 
@@ -25,20 +26,20 @@
 /* auxiliary functions */
 void hexdump(const u_int8_t * buffer, int length)
 {
-       int i;
+       char    line[256];
+       int     n, i;
 
        for (i = 0; i < length; i++) {
                if ((i & 0xf) == 0) {
-                       printf("%04x:", i);
-               }
-               printf(" %02hhx", buffer[i]);
-               if ((i & 0xf) == 0xf) {
-                       printf("\n");
+                       snprintf(line, sizeof(line), "%04x:", i);
                }
+               n = strlen(line);
+               snprintf(line+n, sizeof(line)-n, " %02hhx", buffer[i]);
+               if ((i & 0xf) == 0xf)
+                       syslog(LOG_DEBUG, "%s", line);
        };
-       if ((i & 0xf) != 0xf) {
-               printf("\n");
-       }
+       if ((i & 0xf) != 0xf)
+               syslog(LOG_DEBUG, "%s", line);
 }
 
 int
Index: ETokenDriver//ifdhandler.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/ifdhandler.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 ifdhandler.c
--- ETokenDriver//ifdhandler.c  17 Mar 2002 18:04:54 -0000      1.1.1.1
+++ ETokenDriver//ifdhandler.c  13 Jun 2002 16:55:39 -0000
@@ -4,6 +4,7 @@
 #include <usb.h>
 #include <stdio.h>
 #include <sys/types.h>
+#include <syslog.h>
 
 #include "etoken.h"
 
@@ -24,7 +25,10 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+       syslog(LOG_DEBUG,
+               "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -42,7 +46,10 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+       syslog(LOG_DEBUG,
+               "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -62,8 +69,10 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s: Lun %ld, Tag %lx\n",
+#ifdef DEBUG
+       syslog(LOG_DEBUG, "%s %d %s: Lun %ld, Tag %lx\n",
               __FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Tag);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -79,9 +88,12 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s: Lun %ld, Tag %lx, Length %ld, hexdump follows\n",
+#if 0 && defined(DEBUG)
+       syslog(LOG_DEBUG,
+               "%s %d %s: Lun %ld, Tag %lx, Length %ld, hexdump follows\n",
               __FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Tag, Length);
        hexdump(Value, Length);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -98,7 +110,10 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#ifdef DEBUG
+       syslog(LOG_DEBUG,
+               "%s %d %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -125,8 +140,10 @@
        int rc;
        struct eToken *eToken;
 
-       printf("%s %d %s: Lun %ld, Action %ld\n",
+#ifdef DEBUG
+       syslog(LOG_DEBUG, "%s %d %s: Lun %ld, Action %ld\n",
               __FILE__, __LINE__, __PRETTY_FUNCTION__, Lun, Action);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -141,8 +158,10 @@
                        *AtrLength = get_atr(Atr);
                        return IFD_SUCCESS;
                }
-               printf("%s %d %s: power up failed\n",
+#ifdef DEBUG
+               syslog(LOG_DEBUG, "%s %d %s: power up failed\n",
                       __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#endif
                return IFD_COMMUNICATION_ERROR;
 
        case IFD_POWER_DOWN:
@@ -168,10 +187,13 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s: Lun %ld TxLength %ld RxLength %ld, hexdump follows\n",
+#ifdef DEBUG
+       syslog(LOG_DEBUG,
+               "%s %d %s: Lun %ld TxLength %ld RxLength %ld, hexdump follows\n",
               __FILE__, __LINE__, __PRETTY_FUNCTION__,
               Lun, TxLength, *RxLength);
        hexdump(TxBuffer, TxLength);
+#endif
 
        *RxLength = 0;
        eToken = get_token_by_lun(Lun);
@@ -188,8 +210,11 @@
 {
        struct eToken *eToken;
 
-       printf("%s %d %s: Lun %ld\n",
+#if 0 && defined(DEBUG)
+       syslog(LOG_DEBUG,
+               "%s %d %s: Lun %ld\n",
               __FILE__, __LINE__, __PRETTY_FUNCTION__, Lun);
+#endif
 
        eToken = get_token_by_lun(Lun);
        if (! eToken) {
@@ -213,11 +238,13 @@
        struct eToken *eToken;
        int rc, len_in;
 
-       printf
-           ("%s %d %s: Lun %ld Protocol %ld TxLength %ld RxLength %ld, hexdump 
follows\n",
+#ifdef DEBUG
+       syslog(LOG_DEBUG(
+            "%s %d %s: Lun %ld Protocol %ld TxLength %ld RxLength %ld, hexdump 
+follows\n",
             __FILE__, __LINE__, __PRETTY_FUNCTION__, Lun,
             SendPci.Protocol, TxLength, *RxLength);
        hexdump(TxBuffer, TxLength);
+#endif
 
        len_in = *RxLength;
        *RxLength = 0;          /* should be 0 on all errors */
@@ -246,10 +273,13 @@
        rc = send_command(eToken, TxBuffer, RxBuffer, TxLength, &len_in);
        *RxLength = len_in;
 
-       printf ("%s %d %s: RxLength %ld, hexdump follows\n",
+#ifdef DEBUG
+       syslog(LOG_DEBUG,
+            "%s %d %s: Status %d, RxLength %ld, hexdump follows\n",
             __FILE__, __LINE__, __PRETTY_FUNCTION__, 
-            *RxLength);
+            rc, *RxLength);
        hexdump(RxBuffer, *RxLength);
+#endif
 
        return rc;
 }
Index: ETokenDriver//t1.c
===================================================================
RCS file: /cvsroot/muscleframework/muscle/ETokenDriver/t1.c,v
retrieving revision 1.1.1.1
diff -u -d -r1.1.1.1 t1.c
--- ETokenDriver//t1.c  17 Mar 2002 18:04:55 -0000      1.1.1.1
+++ ETokenDriver//t1.c  13 Jun 2002 16:55:39 -0000
@@ -387,6 +387,12 @@
 
                                /* Check if data available. */
                                if (more == 0) {
+                                       /* last block was with pcb: bit6=0
+                                        * (no more following blocks)
+                                        * so there is no more data to send.
+                                        * if the card is waiting for
+                                        * additional data, then it is wrong.
+                                        * comm error! */
                                        rc = IFD_COMMUNICATION_ERROR;
                                        goto cleanup;
                                }
@@ -394,6 +400,9 @@
                                /* Change N(S) to new value. */
                                eToken->ns ^= 1;
                                /* Make next I-Block. */
+
+                               /* Clear error counter */
+                               rerrcntr = 0;
                        }
 
                        sendlen = min(apdu_cmdlen - sendptr, eToken->ifsc);





***************************************************************
Unix Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/
To unsubscribe send an email to [EMAIL PROTECTED] with
unsubscribe sclinux
***************************************************************

Reply via email to