Changeset 737
- Timestamp:
- 12/07/09 19:13:11 (14 years ago)
- Location:
- branches/smartreader
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/smartreader/csctapi/icc_async.c
r707 r737 100 100 * (that is, if TD1 is available), * otherwise use default T=0 101 101 */ 102 if (np>1)102 /* if (np>1) 103 103 ATR_GetProtocolType (icc->atr, 2, &(icc->protocol_type)); 104 104 … … 106 106 printf("ICC: Detected %s convention processor card T=%d\n",(icc->convention == ATR_CONVENTION_DIRECT ? "direct" : "inverse"), icc->protocol_type); 107 107 #endif 108 108 *///really should let PPS handle this 109 109 /* LED Green */ 110 110 if (IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_GREEN) != IFD_TOWITOKO_OK) -
branches/smartreader/csctapi/ifd_towitoko.c
r707 r737 723 723 req_ts.tv_nsec = 50000000; 724 724 #endif 725 725 726 (*atr) = NULL; 726 727 for(i=0; i<3; i++) … … 981 982 IFD_Towitoko_GetClockRate (IFD * ifd) 982 983 { 983 //return IFD_TOWITOKO_CLOCK_RATE; 984 return (372L * 9600L); 985 /* 984 986 if (ifd->io->cardmhz == 357 || ifd->io->cardmhz == 358) 985 987 return (372L * 9600L); 986 988 else 987 return ifd->io->cardmhz * 10000L; 989 return ifd->io->cardmhz * 10000L; */ 988 990 } 989 991 -
branches/smartreader/csctapi/pps.c
r707 r737 59 59 static int PPS_InitProtocol (PPS * pps); 60 60 61 static void PPS_SelectFirstProtocol (PPS * pps);61 //static void PPS_SelectFirstProtocol (PPS * pps); 62 62 63 63 static BYTE PPS_GetPCK (BYTE * block, unsigned length); … … 88 88 int PPS_Perform (PPS * pps, BYTE * params, unsigned *length) 89 89 { 90 //Performs PPS Exchange on command when *length >0 91 //If unsuccesfull, or when length <= 0 92 //Gets parametes from ATR 93 //If necessary perform PPS session 94 // 95 //Output is pps->params.f,n,d,t set with correct values 96 //and switched SC-device conform these values to correct baudrate 97 90 98 ATR *atr; 91 int ret = PPS_HANDSAKE_ERROR; 92 93 /* Perform PPS Exchange if requested */ 99 int ret; 100 bool PPS_success; 101 102 /* Perform PPS Exchange if requested by command */ 94 103 if ((*length) > 0) 95 104 { … … 121 130 */ 122 131 } 123 if ((*length) <= 0 || ret != PPS_OK) /* Get parameters from ATR */ 124 { 125 PPS_SelectFirstProtocol (pps); 126 127 #ifndef PTS_USE_DEFAULT_TIMINGS 128 atr = ICC_Async_GetAtr (pps->icc); 129 132 PPS_success = PPS_OK; 133 atr = ICC_Async_GetAtr (pps->icc); 134 if ((*length) <= 0 || !PPS_success) // If not by command, or PPS Exchange by command failed: Try PPS Exchange by ATR or Get parameters from ATR 135 { 136 cs_debug("ATR reports smartcard supports %i protocols:",atr->pn); 137 cs_debug("Protocol 1: T0"); 138 int i,point; 139 char txt[50]; 140 for (i=0; i< atr->pn-1; i++) { 141 sprintf(txt,"Protocol %01i: ",i+2); 142 point = 12; 143 if (atr->ib[i][ATR_INTERFACE_BYTE_TA].present) { 144 sprintf((char *)txt+point,"TA%i=%02X ",i,atr->ib[i][ATR_INTERFACE_BYTE_TA].value); 145 point +=7; 146 } 147 if (atr->ib[i][ATR_INTERFACE_BYTE_TB].present) { 148 sprintf((char *)txt+point,"TB%i=%02X ",i,atr->ib[i][ATR_INTERFACE_BYTE_TB].value); 149 point +=7; 150 } 151 if (atr->ib[i][ATR_INTERFACE_BYTE_TC].present) { 152 sprintf((char *)txt+point,"TC%i=%02X ",i,atr->ib[i][ATR_INTERFACE_BYTE_TC].value); 153 point +=7; 154 } 155 if (atr->ib[i][ATR_INTERFACE_BYTE_TD].present) { 156 BYTE TD = atr->ib[i][ATR_INTERFACE_BYTE_TD].value; 157 sprintf((char *)txt+point,"TD%i=%02X ",i,TD); 158 point +=7; 159 sprintf((char *)txt+point,"(T%i)",TD&0x0F); 160 } 161 cs_debug("%s",txt); 162 } 163 164 //If more than one protocol type and/or TA1 parameter values other than the default values and/or N equeal to 255 is/are indicated in the answer to reset, the card shall know unambiguously, after having sent the answer to reset, which protocol type or/and transmission parameter values (FI, D, N) will be used. Consequently a selection of the protocol type and/or the transmission parameters values shall be specified. 130 165 ATR_GetParameter (atr, ATR_PARAMETER_N, &(pps->parameters.n)); 131 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 132 ATR_GetParameter (atr, ATR_PARAMETER_F, &(pps->parameters.f)); 133 #endif 134 } 135 136 ret = PPS_InitICC(pps); 137 138 if (ret != PPS_OK) 139 return ret; 140 141 #ifdef DEBUG_PROTOCOL 142 printf("PPS: T=%X, F=%.0f, D=%.6f, N=%.0f\n", 166 if (atr->pn > 1 || (atr->ib[0][ATR_INTERFACE_BYTE_TA].present == TRUE && atr->ib[0][ATR_INTERFACE_BYTE_TA].value != 0x11) || pps->parameters.n == 255) { 167 // PTSS PTS0 PTS1 PTS2 PTS3 PCK 168 // PTSS PTS0 PTS1 PCK 169 BYTE req[] = { 0xFF, 0x10, 0x00, 0x00 }; //we currently do not support PTS2, standard guardtimes 170 171 int p; //protocol 1 = T0 , protocol 2 = TD1, 3=TD2 etc 172 for (p=2; p<atr->pn; p++) { 173 ATR_GetProtocolType(atr,p,&(pps->parameters.t)); //get protocol from TDi 174 req[1]=0x10 | pps->parameters.t; //PTS0 always flags PTS1 to be sent always 175 if (ATR_GetInterfaceByte (atr, p, ATR_INTERFACE_BYTE_TA, &req[2]) != ATR_OK) //PTS1 176 continue; 177 //req[3]=PPS_GetPCK(req,sizeof(req)-1); will be set by PPS_Exchange 178 int len = sizeof(req); 179 ret = PPS_Exchange (pps, req, &len); 180 if (ret == PPS_OK) { 181 pps->parameters.d = req[2] & 0x0F; 182 BYTE FI = req[2] >> 4; 183 BYTE DI = req[2] & 0x0F; 184 pps->parameters.f = (double) (atr_f_table[FI]); 185 pps->parameters.d = (double) (atr_d_table[DI]); 186 PPS_success = TRUE; 187 cs_debug("PTS Succesfull, selected protocol %i: T%i, F=%.0f, D=%.6f, N=%.0f\n", p, pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 188 break; 189 } 190 else 191 cs_ddump(req,4,"PTS Failure for protocol %i, response:",p); 192 } 193 } 194 195 if (!PPS_success) {//last PPS not succesfull 196 // Get protocol offered by interface bytes T*2 if TD1 available, 197 if (atr->pn>1) { 198 ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); 199 ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); 200 ATR_GetParameter (atr, ATR_PARAMETER_F, &(pps->parameters.f)); 201 cs_debug("No PTS, selected protocol 2: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 202 } 203 else {//otherwise use default T0 204 pps->parameters.t = ATR_PROTOCOL_TYPE_T0; 205 pps->parameters.d = ATR_DEFAULT_D; 206 pps->parameters.f = ATR_DEFAULT_F; 207 cs_debug("No PTS, selected protocol 1: T%i, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); 208 } 209 } 210 }//end length<0 211 212 #ifdef DEBUG_PROTOCOL 213 printf("PPS: T=%i, F=%.0f, D=%.6f, N=%.0f\n", 143 214 pps->parameters.t, 144 215 pps->parameters.f, … … 146 217 pps->parameters.n); 147 218 #endif 219 220 ret = PPS_InitICC(pps); 221 222 if (ret != PPS_OK) 223 return ret; 148 224 149 225 /* Initialize selected protocol with selected parameters */ 226 //this is really administrattive shit only, remove 150 227 ret = PPS_InitProtocol (pps); 151 228 … … 191 268 printf ("\n"); 192 269 #endif 270 271 cs_debug("PTS: Sending request: %s", cs_hexdump(1, params, len_request)); 193 272 194 273 /* Send PPS request */ … … 212 291 #endif 213 292 293 cs_debug("PTS: Receiving confirm: %s", cs_hexdump(1, confirm, len_confirm)); 294 214 295 if (!PPS_Match (params, len_request, confirm, len_confirm)) 215 296 ret = PPS_HANDSAKE_ERROR; … … 256 337 { 257 338 #ifdef SCI_DEV 258 //case readertype = internal 259 //code for setting parameters to SCI_DEV (currently in ifd_towitoko.c in ResetAsync_ICC should be placed here 339 //case readertype = internal 340 //params.t = pps->parameters.t 341 //params.f = pps->parameters.f 342 //params.d = pps->parameters.d 343 //if (pps->parameters.n == 255) 344 // params.EGT = 0; 345 //else 346 // params.EGT = pps->parameters.n; 347 //params.WWT should be computed; standard WWT see protocol_T0 348 //In an answer to reset, the interface character TC2 codes the integer value WI over eight bits b8 to b1. When no TC2 appears in the answer to reset, the default value of WI is 10. 260 349 //if ok return PPS_OK; 261 350 //else return PPS_ICC_ERROR; … … 265 354 266 355 baudrate = pps->parameters.d * ICC_Async_GetClockRate (pps->icc) / pps->parameters.f; 267 //FIXME notice that cardmhz is taken into account here268 //not sure whether that goes ok when cardmhz = 600269 //if not then IFD_GetClockRate should be devaluated to returning the DEFINED 372L * 9600L (like it usd to be..)270 356 271 357 #ifdef DEBUG_PROTOCOL … … 349 435 return PPS_PROTOCOL_ERROR; 350 436 } 351 437 /* 352 438 static void PPS_SelectFirstProtocol (PPS * pps) 353 439 { … … 359 445 ATR_GetNumberOfProtocols (atr, &np); 360 446 361 /*362 *Get protocol offered by interface bytes T*2 if available,363 *(that is, if TD1 is available), * otherwise use default T=0364 */447 448 // Get protocol offered by interface bytes T*2 if available, 449 // (that is, if TD1 is available), * otherwise use default T=0 450 365 451 if (np>1) 366 452 ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); … … 370 456 #endif 371 457 } 372 458 */ 373 459 static BYTE PPS_GetPCK (BYTE * block, unsigned length) 374 460 { -
branches/smartreader/module-cccam.c
r727 r737 614 614 while (card) { 615 615 if (card->caid == cur_er->caid) { // caid matches 616 616 617 LLIST_ITR sitr; 617 618 uint16 *sid = llist_itr_init(card->badsids, &sitr); 618 619 while (sid) { 619 sid = llist_itr_remove(&sitr); 620 if (*sid == cur_er->srvid) sid = llist_itr_remove(&sitr); 621 else sid = llist_itr_next(&sitr); 620 622 } 621 623 llist_itr_release(&sitr);
Note:
See TracChangeset
for help on using the changeset viewer.