Changeset 3391 for trunk/reader-videoguard2.c
- Timestamp:
- 10/06/10 08:41:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/reader-videoguard2.c
r3366 r3391 3 3 #include "reader-videoguard-common.h" 4 4 5 #define cs_log(x...) cs_log("[videoguard2-reader] "x) 5 6 #ifdef WITH_DEBUG 6 #define cs_debug(x...) cs_debug("[ reader-videoguard2] "x)7 #define cs_debug(x...) cs_debug("[videoguard2-reader] "x) 7 8 #endif 8 9 … … 197 198 cw[3] = (cw[0] + cw[1] + cw[2]) & 0xFF; 198 199 cw[7] = (cw[4] + cw[5] + cw[6]) & 0xFF; 199 cs_ddump(cw, 8, " Postprocessed Case 1 DW:");200 cs_ddump(cw, 8, "[videoguard2-reader] Postprocessed Case 1 DW:"); 200 201 break; 201 202 } … … 207 208 MD5(buffer, 8 + ecm_header_data[ecmi] - 2, md5_digest); 208 209 memcpy(cw, md5_digest, 8); 209 cs_ddump(cw, 8, " Postprocessed Case 3 DW:");210 cs_ddump(cw, 8, "[videoguard2-reader] Postprocessed Case 3 DW:"); 210 211 break; 211 212 } … … 234 235 l=do_cmd(reader,ins2a,NULL,NULL,cta_res); 235 236 if(l<0 || !status_ok(cta_res+l)){ 236 cs_log ("[videoguard2-reader]classD0 ins2a: failed");237 cs_log("classD0 ins2a: failed"); 237 238 return; 238 239 } … … 241 242 static const unsigned char ins76007f[5] = { 0xD0,0x76,0x00,0x7f,0x02 }; 242 243 if(!write_cmd_vg(ins76007f,NULL) || !status_ok(cta_res+2)){ 243 cs_log ("[videoguard2-reader]classD0 ins76007f: failed");244 cs_log("classD0 ins76007f: failed"); 244 245 return; 245 246 } … … 257 258 starttier = 0; 258 259 } 259 // check to see if specified start tier is blank and if sostart at 0 and ignore blank tiers260 // check to see if specified start tier is blank and if blank, start at 0 and ignore blank tiers 260 261 ins76[2]=starttier; 261 262 l=do_cmd(reader,ins76,NULL,NULL,cta_res); … … 275 276 unsigned short tier_id = (cta_res[2] << 8) | cta_res[3]; 276 277 char *tier_name = get_tiername(tier_id, reader->caid[0]); 277 if( reader->card_tierstart == -1){278 cs_ ri_log(reader, "[videoguard2-reader] tier-number: 0x%02x, tier: %04x",i,tier_id);278 if(!stopemptytier){ 279 cs_debug("tier: %04x, tier-number: 0x%02x",tier_id,i); 279 280 } 280 281 cs_ri_log(reader, "[videoguard2-reader] tier: %04x, expiry date: %04d/%02d/%02d-%02d:%02d:%02d %s",tier_id,y,m,d,H,M,S,tier_name); … … 286 287 { 287 288 get_hist; 288 if ((hist_size < 7) || (hist[1] != 0xB0) || (hist[4] != 0xFF) || (hist[5] != 0x4A) || (hist[6] != 0x50)) 289 return ERROR; 290 cs_log("[videoguard2-reader] in videoguard2_card_init"); 289 if ((hist_size < 7) || (hist[1] != 0xB0) || (hist[4] != 0xFF) || (hist[5] != 0x4A) || (hist[6] != 0x50)){ 290 cs_debug("failed history check"); 291 return ERROR; 292 } 293 cs_debug("passed history check"); 291 294 292 295 get_atr; … … 304 307 } 305 308 306 cs_ ri_log(reader, "[videoguard2-reader]type: %s, baseyear: %i", reader->card_desc, reader->card_baseyear);309 cs_debug("type: %s, baseyear: %i", reader->card_desc, reader->card_baseyear); 307 310 if(reader->ndsversion == NDS2){ 308 cs_ log("[videoguard2-reader]forced to NDS2");311 cs_debug("forced to NDS2"); 309 312 } 310 313 … … 316 319 ins7401[3]=0x80; // from newcs log 317 320 ins7401[4]=0x01; 318 if((l=read_cmd_len(reader,ins7401))<0) return ERROR; //not a videoguard2/NDS card or communication error 321 if((l=read_cmd_len(reader,ins7401))<0){ //not a videoguard2/NDS card or communication error 322 return ERROR; 323 } 319 324 ins7401[3]=0x00; 320 325 ins7401[4]=l; 321 326 if(!write_cmd_vg(ins7401,NULL) || !status_ok(cta_res+l)) { 322 cs_log ("[videoguard2-reader]classD0 ins7401: failed - cmd list not read");323 return ERROR; 324 327 cs_log("classD0 ins7401: failed - cmd list not read"); 328 return ERROR; 329 } 325 330 326 331 memorize_cmd_table (reader,cta_res,l); … … 330 335 static const unsigned char ins7416[5] = { 0xD0,0x74,0x16,0x00,0x00 }; 331 336 if(do_cmd(reader,ins7416,NULL,NULL,cta_res)<0) { 332 cs_log ("[videoguard2-reader]classD0 ins7416: failed");333 return ERROR; 334 337 cs_log("classD0 ins7416: failed"); 338 return ERROR; 339 } 335 340 336 341 unsigned char ins36[5] = { 0xD0,0x36,0x00,0x00,0x00 }; … … 349 354 if((ins36[4]=read_cmd_len(reader,ins36))==0 && cmd_exists(reader,ins5e)) { 350 355 if(!write_cmd_vg(ins5e,NULL) || !status_ok(cta_res+2)){ 351 cs_log ("[videoguard2-reader]classD0 ins5e: failed");356 cs_log("classD0 ins5e: failed"); 352 357 } else { 353 358 ins36[3] = cta_res[0]; … … 357 362 l=ins36[4]; 358 363 if(!write_cmd_vg(ins36,NULL) || !status_ok(cta_res+l)){ 359 cs_log ("[videoguard2-reader]classD0 ins36: failed");364 cs_log("classD0 ins36: failed"); 360 365 return ERROR; 361 366 } … … 364 369 memcpy(buff+5+l,cta_res+l,2); 365 370 if(l<13) 366 cs_log(" [videoguard2-reader] classD0 ins36: too short answer");371 cs_log("classD0 ins36: answer too short"); 367 372 else if (buff[7] > 0x0F) 368 373 cs_log("[videoguard2-reader] classD0 ins36: encrypted - can't parse"); … … 412 417 break; 413 418 default: /* default to assume a length byte */ 414 cs_log(" [videoguard2-reader]classD0 ins36: returned unknown type=0x%02X - parsing may fail", buff[i]);419 cs_log("classD0 ins36: returned unknown type=0x%02X - parsing may fail", buff[i]); 415 420 i+=buff[i+1]+2; 416 421 } … … 419 424 420 425 if(!boxidOK) { 421 cs_log (" [videoguard2-reader]no boxID available");426 cs_log ("no boxID available"); 422 427 return ERROR; 423 428 } … … 428 433 memcpy(payload4C,boxID,4); 429 434 if(!write_cmd_vg(ins4C,payload4C) || !status_ok(cta_res+l)) { 430 cs_log("[videoguard2-reader] classD0 ins4C: failed - sending boxid failed"); 431 return ERROR; 432 } 433 cs_debug_mask(D_READER, "classD0 cmd4C status: %02x %02x",cta_res[0],cta_res[1]); 434 435 cs_log("classD0 ins4C: failed - sending boxid failed"); 436 return ERROR; 437 } 435 438 436 439 //short int SWIRDstatus = cta_res[1]; 437 440 static const unsigned char ins58[5] = { 0xD0,0x58,0x00,0x00,0x00 }; 438 l=do_cmd(reader,ins58,NULL,buff,cta_res); 439 cs_debug_mask(D_READER, "classD0 cmd58 length: %d status: %02x %02x",l,cta_res[0],cta_res[1]); 441 l=do_cmd(reader,ins58,NULL,NULL,cta_res); 440 442 if(l<0) { 441 cs_log(" [videoguard2-reader]classD0 ins58: failed");443 cs_log("classD0 ins58: failed"); 442 444 return ERROR; 443 445 } … … 452 454 453 455 /* 454 cs_log (" [videoguard2-reader]INS58 : Fuse byte=0x%02X, IRDStatus=0x%02X", cta_res[2],SWIRDstatus);456 cs_log ("INS58 : Fuse byte=0x%02X, IRDStatus=0x%02X", cta_res[2],SWIRDstatus); 455 457 if (SWIRDstatus==4) { 456 458 // If swMarriage=4, not married then exchange for BC Key 457 cs_log (" [videoguard2-reader]Card not married, exchange for BC Keys");459 cs_log ("Card not married, exchange for BC Keys"); 458 460 */ 459 461 … … 465 467 l=do_cmd(reader,insB4,tbuff,NULL,cta_res); 466 468 if(l<0 || !status_ok(cta_res)) { 467 cs_log ("[videoguard2-reader] classD0 insB4: failed (%02X%02X)", cta_res[0], cta_res[1]);469 cs_log("classD0 insB4: failed"); 468 470 return ERROR; 469 471 } … … 472 474 l=do_cmd(reader,insBC,NULL,NULL,cta_res); 473 475 if(l<0) { 474 cs_log(" [videoguard2-reader]classD0 insBC: failed");476 cs_log("classD0 insBC: failed"); 475 477 return ERROR; 476 478 } … … 481 483 l=do_cmd(reader,insBE,NULL,NULL,cta_res); 482 484 if(l<0) { 483 cs_log(" [videoguard2-reader]classD3 insBE: failed");485 cs_log("classD3 insBE: failed"); 484 486 return ERROR; 485 487 } … … 488 490 l=do_cmd(reader,ins58a,NULL,NULL,cta_res); 489 491 if(l<0) { 490 cs_log(" [videoguard2-reader]classD1 ins58: failed");492 cs_log("classD1 ins58: failed"); 491 493 return ERROR; 492 494 } … … 495 497 l=do_cmd(reader,ins4Ca,payload4C,NULL,cta_res); 496 498 if(l<0 || !status_ok(cta_res)) { 497 cs_log(" [videoguard2-reader]classD1 ins4Ca: failed");499 cs_log("classD1 ins4Ca: failed"); 498 500 return ERROR; 499 501 } … … 506 508 AES_set_decrypt_key(dimeno_magic,128,&(reader->astrokey)); 507 509 508 cs_ri_log(reader, "[videoguard2-reader] type: %s, caid: %04X , serial: %02X%02X%02X%02X, BoxID: %02X%02X%02X%02X",510 cs_ri_log(reader, "[videoguard2-reader] type: %s, caid: %04X", 509 511 reader->card_desc, 510 reader->caid[0], 512 reader->caid[0]); 513 cs_ri_log(reader, "[videoguard2-reader] serial: %02X%02X%02X%02X, BoxID: %02X%02X%02X%02X, baseyear: %i", 511 514 reader->hexserial[2],reader->hexserial[3],reader->hexserial[4],reader->hexserial[5], 512 boxID[0],boxID[1],boxID[2],boxID[3] );513 514 cs_log(" [videoguard2-reader]ready for requests");515 boxID[0],boxID[1],boxID[2],boxID[3], 516 reader->card_baseyear); 517 cs_log("ready for requests"); 515 518 516 519 return OK; … … 535 538 l = do_cmd(reader,ins40,tbuff,NULL,cta_res); 536 539 if(l<0 || !status_ok(cta_res)) { 537 cs_log (" [videoguard2-reader]classD0 ins40: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]);540 cs_log ("classD0 ins40: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]); 538 541 return ERROR; 539 542 } else { 540 543 l = do_cmd(reader,ins54,NULL,rbuff,cta_res); 541 544 if(l<0 || !status_ok(cta_res+l)) { 542 cs_log(" [reader-videoguard2]classD3 ins54: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]);545 cs_log("classD3 ins54: (%d) status not ok %02x %02x",l,cta_res[0],cta_res[1]); 543 546 return ERROR; 544 547 } else { 548 545 549 // Log decrypted INS54 546 // cs_dump (rbuff, 5, " Decrypted INS54:");550 // cs_dump (rbuff, 5, "[videoguard2-reader] Decrypted INS54:"); 547 551 // cs_dump (rbuff + 5, rbuff[4], ""); 548 552 549 553 if (!cw_is_valid(rbuff+5,0)){ //sky cards report 90 00 = ok but send cw = 00 when channel not subscribed 550 cs_log(" [reader-videoguard2]classD3 ins54: status 90 00 = ok but cw=00 -> channel not subscribed " );554 cs_log("classD3 ins54: status 90 00 = ok but cw=00 -> channel not subscribed " ); 551 555 return ERROR; 552 556 } … … 617 621 case VG_EMMTYPE_G: 618 622 ep->type=GLOBAL; 619 cs_debug_mask(D_EMM, " VIDEOGUARD2EMM: GLOBAL");623 cs_debug_mask(D_EMM, "[videoguard2-reader] EMM: GLOBAL"); 620 624 return TRUE; 621 625 622 626 case VG_EMMTYPE_U: 623 cs_debug_mask(D_EMM, " VIDEOGUARD2EMM: UNIQUE");627 cs_debug_mask(D_EMM, "[videoguard2-reader] EMM: UNIQUE"); 624 628 ep->type=UNIQUE; 625 629 if (ep->emm[1] == 0) // detected UNIQUE EMM from cccam (there is no serial) … … 638 642 case VG_EMMTYPE_S: 639 643 ep->type=SHARED; 640 cs_debug_mask(D_EMM, " VIDEOGUARD2EMM: SHARED");644 cs_debug_mask(D_EMM, "[videoguard2-reader] EMM: SHARED"); 641 645 return TRUE; // FIXME: no check for SA 642 646 … … 697 701 } 698 702 699 int videoguard2_do_emm(struct s_reader * reader, EMM_PACKET *ep)703 static int videoguard2_do_emm(struct s_reader * reader, EMM_PACKET *ep) 700 704 { 701 705 unsigned char cta_res[CTA_RES_LEN]; … … 735 739 { 736 740 /* info is displayed in init, or when processing info */ 737 cs_log(" [videoguard2-reader]card detected");738 cs_log(" [videoguard2-reader]type: %s", reader->card_desc );739 vg2_read_tiers 741 cs_log("card detected"); 742 cs_log("type: %s", reader->card_desc ); 743 vg2_read_tiers(reader); 740 744 return OK; 741 745 }
Note:
See TracChangeset
for help on using the changeset viewer.