[Pcsclite-cvs-commit] Drivers/ccid/src ifdhandler.c,1.10,1.11

rousseau@quantz.debian.org rousseau@quantz.debian.org
Thu, 15 Jan 2004 15:10:15 +0100


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory quantz:/tmp/cvs-serv22931

Modified Files:
	ifdhandler.c 
Log Message:
add support of T=1 in TPDU mode


Index: ifdhandler.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ifdhandler.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ifdhandler.c	15 Jan 2004 13:45:37 -0000	1.10
+++ ifdhandler.c	15 Jan 2004 14:10:13 -0000	1.11
@@ -27,6 +27,7 @@
 #include "debug.h"
 #include "utils.h"
 #include "commands.h"
+#include "ccid.h"
 
 #ifdef HAVE_PTHREAD
 #include <pthread.h>
@@ -103,6 +104,9 @@
 	/* Maybe we have a special treatment for this reader */
 	ccid_open_hack(Lun);
 
+	/* initialize T=1 context */
+	Protocol_T1_Close(&((get_ccid_slot(Lun)) -> t1));
+
 #ifdef HAVE_PTHREAD
 	pthread_mutex_unlock(&ifdh_context_mutex);
 #endif
@@ -355,6 +359,10 @@
 			memcpy(Atr, pcbuffer, *AtrLength);
 			memcpy(CcidSlots[LunToReaderIndex(Lun)].pcATRBuffer,
 				pcbuffer, *AtrLength);
+
+			/* set T=1 context */
+			Protocol_T1_Init(&((get_ccid_slot(Lun)) -> t1), Lun);
+
 			break;
 
 		case IFD_POWER_DOWN:
@@ -367,6 +375,10 @@
 				MASK_POWERFLAGS_PDWN;
 			/* send the command */
 			return_value = CmdPowerOff(Lun);
+
+			/* clear T=1 context */
+			Protocol_T1_Close(&((get_ccid_slot(Lun)) -> t1));
+
 			break;
 
 		default:
@@ -426,17 +438,8 @@
 		return IFD_COMMUNICATION_ERROR;
 
 	rx_length = *RxLength;
-	switch (SendPci.Protocol)
-	{
-		case T_0:
-		case T_1:
-			return_value = CmdXfrBlock(Lun, TxLength, TxBuffer, &rx_length,
-				RxBuffer);
-			break;
-
-		default:
-			return_value = IFD_PROTOCOL_NOT_SUPPORTED;
-	}
+	return_value = CmdXfrBlock(Lun, TxLength, TxBuffer, &rx_length, RxBuffer,
+		SendPci.Protocol);
 	*RxLength = rx_length;
 
 	return return_value;