[Pcsclite-cvs-commit] PCSC/src prothandler.c,1.13,1.14

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv20135

Modified Files:
	prothandler.c 
Log Message:
PHSetProtocol(): returns SET_PROTOCOL_PPS_FAILED if IFDSetPTS() is
supported but fails:
ISO 7816-3:1997 ch. 7.2 PPS protocol page 14
- If the PPS exchange is unsuccessful, then the interface device shall
  either reset or reject the card.


Index: prothandler.c
===================================================================
RCS file: /cvsroot/pcsclite/PCSC/src/prothandler.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- prothandler.c	22 Jun 2004 14:33:28 -0000	1.13
+++ prothandler.c	29 Jun 2004 07:48:34 -0000	1.14
@@ -70,7 +70,9 @@
  * SCardConnect has a DWORD dwPreferredProtocols that is a bitmask of what 
  * protocols to use.  Basically, if T=N where N is not zero will be used
  * first if it is available in ucAvailable.  Otherwise it will always
- * default to T=0.  Do nothing if the default rContext->dwProtocol is OK. 
+ * default to T=0.
+ *
+ * IFDSetPTS() is _always_ called so that the driver can initialise its data
  */
 
 DWORD PHSetProtocol(struct ReaderContext * rContext,
@@ -82,7 +84,7 @@
 
 	/* App has specified no protocol */
 	if (dwPreferred == 0)
-		return -1;
+		return SET_PROTOCOL_WRONG_ARGUMENT;
 
 	/* requested protocol is not available */
 	if (! (dwPreferred & ucAvailable))
@@ -101,7 +103,7 @@
 		 */
 		DebugLogB("Protocol T=%d requested but unsupported by the card",
 			(SCARD_PROTOCOL_T0 == dwPreferred) ? 0 : 1);
-		return -1;
+		return SET_PROTOCOL_WRONG_ARGUMENT;
 	}
 
 	/* set default value */
@@ -118,7 +120,7 @@
 			ucChosen = SCARD_PROTOCOL_T0;
 		else
 			/* App wants unsupported protocol */
-			return -1;
+			return SET_PROTOCOL_WRONG_ARGUMENT;
 
 	DebugLogB("Attempting PTS to T=%d",
 		(SCARD_PROTOCOL_T0 == ucChosen ? 0 : 1));
@@ -131,8 +133,16 @@
 			DebugLogB("PTS not supported by driver, using T=%d",
 				(SCARD_PROTOCOL_T0 == protocol) ? 0 : 1);
 		else
+		{
 			DebugLogB("PTS failed, using T=%d",
 				(SCARD_PROTOCOL_T0 == protocol) ? 0 : 1);
+
+ 			/* ISO 7816-3:1997 ch. 7.2 PPS protocol page 14
+ 			 * - If the PPS exchange is unsuccessful, then the interface device
+ 			 *   shall either reset or reject the card.
+ 			 */
+ 			return SET_PROTOCOL_PPS_FAILED;
+ 		}
 
 	return protocol;
 }