Changeset 8483
- Timestamp:
- 03/06/13 01:32:01 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r8480 r8483 1045 1045 struct s_client *next; //make client a linked list 1046 1046 struct s_client *nexthashed; 1047 };1048 1049 struct geo_cache { //for viaccess var in s_reader:1050 uint32_t provid;1051 uchar geo[256];1052 uchar geo_len;1053 int32_t number_ecm;1054 1047 }; 1055 1048 … … 1333 1326 BIGNUM exp; 1334 1327 BIGNUM ucpk; 1335 ////variables from reader-viaccess.c1336 struct geo_cache last_geo;1337 1328 #ifdef WITH_LB 1338 1329 int32_t lb_weight; //loadbalance weight factor, if unset, weight=100. The higher the value, the higher the usage-possibility -
trunk/reader-viaccess.c
r8454 r8483 5 5 #include "oscam-emm.h" 6 6 #include "reader-common.h" 7 8 struct geo_cache { 9 uint32_t provid; 10 uint8_t geo[256]; 11 uint8_t geo_len; 12 int32_t number_ecm; 13 }; 14 15 struct viaccess_data { 16 struct geo_cache last_geo; 17 int32_t reassemble_emm_len; 18 uint8_t reassemble_emm[512]; 19 }; 7 20 8 21 struct via_date { … … 238 251 return ERROR; 239 252 240 memset(&reader->last_geo, 0, sizeof(reader->last_geo)); 253 if (!cs_malloc(&reader->csystem_data, sizeof(struct viaccess_data))) 254 return ERROR; 255 struct viaccess_data *csystem_data = reader->csystem_data; 256 241 257 write_cmd(insFAC, ins8702_data); 242 258 if ((cta_res[cta_lr-2]==0x90) && (cta_res[cta_lr-1]==0x00)) { … … 245 261 write_cmd(ins8706, NULL); 246 262 if ((cta_res[cta_lr-2]==0x90) && (cta_res[cta_lr-1]==0x00)) { 247 reader->last_geo.number_ecm =(cta_res[2]<<8) | (cta_res[3]);248 rdr_log(reader, "using ecm #%x for long viaccess ecm", reader->last_geo.number_ecm);263 csystem_data->last_geo.number_ecm =(cta_res[2]<<8) | (cta_res[3]); 264 rdr_log(reader, "using ecm #%x for long viaccess ecm",csystem_data->last_geo.number_ecm); 249 265 } 250 266 } … … 322 338 unsigned char insf8[] = { 0xca,0xf8,0x00,0x00,0x00 }; // set geographic info 323 339 static const unsigned char insc0[] = { 0xca,0xc0,0x00,0x00,0x12 }; // read dcw 340 struct viaccess_data *csystem_data = reader->csystem_data; 324 341 325 342 // //XXX what is the 4th byte for ?? … … 414 431 if(nanoLen>5) { 415 432 curnumber_ecm =(ecm88Data[6]<<8) | (ecm88Data[7]); 416 rdr_debug_mask(reader, D_READER, "checking if the ecm number (%x) match the card one (%x)",curnumber_ecm, reader->last_geo.number_ecm);433 rdr_debug_mask(reader, D_READER, "checking if the ecm number (%x) match the card one (%x)",curnumber_ecm,csystem_data->last_geo.number_ecm); 417 434 // if we have an ecm number we check it. 418 435 // we can't assume that if the nano len is 5 or more we have an ecm number 419 436 // as some card don't support this 420 if( reader->last_geo.number_ecm > 0 ) {421 if ( reader->last_geo.number_ecm == curnumber_ecm && !( ecm88Data[nanoLen-1] == 0x01 && (ecm88Data[2] == 0x03 && ecm88Data[3] == 0x0B && ecm88Data[4] == 0x00 ) )) {437 if( csystem_data->last_geo.number_ecm > 0 ) { 438 if (csystem_data->last_geo.number_ecm == curnumber_ecm && !( ecm88Data[nanoLen-1] == 0x01 && (ecm88Data[2] == 0x03 && ecm88Data[3] == 0x0B && ecm88Data[4] == 0x00 ) )) { 422 439 keynr=ecm88Data[5]; 423 440 rdr_debug_mask(reader, D_READER, "keyToUse = %02x, ECM ending with %02x",ecm88Data[5], ecm88Data[nanoLen-1]); … … 470 487 // 471 488 472 if( reader->last_geo.provid != provid )473 { 474 reader->last_geo.provid = provid;475 reader->last_geo.geo_len = 0;476 reader->last_geo.geo[0] = 0;489 if( csystem_data->last_geo.provid != provid ) 490 { 491 csystem_data->last_geo.provid = provid; 492 csystem_data->last_geo.geo_len = 0; 493 csystem_data->last_geo.geo[0] = 0; 477 494 write_cmd(insa4, ident); // set provider 478 495 } … … 513 530 if(ecmf8Len) 514 531 { 515 if( reader->last_geo.geo_len!=ecmf8Len ||516 memcmp( reader->last_geo.geo, ecmf8Data, reader->last_geo.geo_len))532 if( csystem_data->last_geo.geo_len!=ecmf8Len || 533 memcmp(csystem_data->last_geo.geo, ecmf8Data, csystem_data->last_geo.geo_len)) 517 534 { 518 memcpy( reader->last_geo.geo, ecmf8Data, ecmf8Len);519 reader->last_geo.geo_len= ecmf8Len;535 memcpy(csystem_data->last_geo.geo, ecmf8Data, ecmf8Len); 536 csystem_data->last_geo.geo_len= ecmf8Len; 520 537 insf8[3]=keynr; 521 538 insf8[4]=ecmf8Len; … … 688 705 //static const unsigned char insc8[] = { 0xca,0xc8,0x00,0x00,0x02 }; // read extended status 689 706 // static const unsigned char insc8Data[] = { 0x00,0x00 }; // data for read extended status 707 struct viaccess_data *csystem_data = reader->csystem_data; 690 708 691 709 int32_t emmdatastart=7; … … 734 752 735 753 // check if the provider changes. If yes, set the new one. If not, don't .. card will return an error if we do. 736 if( reader->last_geo.provid != emm_provid ) {754 if( csystem_data->last_geo.provid != emm_provid ) { 737 755 write_cmd(insa4, ident); 738 756 if( cta_res[cta_lr-2]!=0x90 || cta_res[cta_lr-1]!=0x00 ) { … … 744 762 } 745 763 // as we are maybe changing the used provider, clear the cache, so the next ecm will re-select the correct one 746 reader->last_geo.provid = 0;747 reader->last_geo.geo_len = 0;748 reader->last_geo.geo[0] = 0;764 csystem_data->last_geo.provid = 0; 765 csystem_data->last_geo.geo_len = 0; 766 csystem_data->last_geo.geo[0] = 0; 749 767 750 768 } … … 918 936 static const uchar cls[] = { 0x00, 0x21, 0xff, 0x9f}; 919 937 static const uchar pin[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04}; 920 921 reader->last_geo.provid = 0; 922 reader->last_geo.geo_len = 0; 923 reader->last_geo.geo[0] = 0; 938 struct viaccess_data *csystem_data = reader->csystem_data; 939 940 csystem_data->last_geo.provid = 0; 941 csystem_data->last_geo.geo_len = 0; 942 csystem_data->last_geo.geo[0] = 0; 924 943 925 944 rdr_log(reader, "card detected"); … … 995 1014 static bool viaccess_reassemble_emm(struct s_reader *reader, EMM_PACKET *ep) 996 1015 { 1016 struct viaccess_data *csystem_data = reader->csystem_data; 997 1017 uint8_t *buffer = ep->emm; 998 1018 int16_t *len = &ep->emmlen; … … 1007 1027 case 0x8d: 1008 1028 // emm-s part 1 1009 if (!memcmp( reader->reassemble_emm, buffer, *len))1029 if (!memcmp(csystem_data->reassemble_emm, buffer, *len)) 1010 1030 return 0; 1011 1031 1012 1032 // copy first part of the emm-s 1013 memcpy( reader->reassemble_emm, buffer, *len);1014 reader->reassemble_emm_len=*len;1033 memcpy(csystem_data->reassemble_emm, buffer, *len); 1034 csystem_data->reassemble_emm_len=*len; 1015 1035 //cs_ddump_mask(D_READER, buffer, len, "viaccess global emm:"); 1016 1036 return 0; … … 1018 1038 case 0x8e: 1019 1039 // emm-s part 2 1020 if (! reader->reassemble_emm_len) return 0;1040 if (!csystem_data->reassemble_emm_len) return 0; 1021 1041 1022 1042 //extract nanos from emm-gh and emm-s … … 1025 1045 cs_debug_mask(D_DVBAPI, "[viaccess] %s: start extracting nanos", __func__); 1026 1046 //extract from emm-gh 1027 for (i=3; i< reader->reassemble_emm_len; i+=reader->reassemble_emm[i+1]+2) {1047 for (i=3; i<csystem_data->reassemble_emm_len; i+=csystem_data->reassemble_emm[i+1]+2) { 1028 1048 //copy nano (length determined by i+1) 1029 memcpy(emmbuf+pos, reader->reassemble_emm+i, reader->reassemble_emm[i+1]+2);1030 pos+= reader->reassemble_emm[i+1]+2;1049 memcpy(emmbuf+pos, csystem_data->reassemble_emm+i, csystem_data->reassemble_emm[i+1]+2); 1050 pos+=csystem_data->reassemble_emm[i+1]+2; 1031 1051 } 1032 1052 … … 1058 1078 buffer[2]=pos-3; 1059 1079 1060 cs_ddump_mask(D_DVBAPI, reader->reassemble_emm, reader->reassemble_emm_len, "[viaccess] %s: emm-gh", __func__);1080 cs_ddump_mask(D_DVBAPI, csystem_data->reassemble_emm, csystem_data->reassemble_emm_len, "[viaccess] %s: emm-gh", __func__); 1061 1081 cs_ddump_mask(D_DVBAPI, buffer, pos, "[viaccess] %s: assembled emm", __func__); 1062 1082
Note:
See TracChangeset
for help on using the changeset viewer.