|
SASC
DVBSoftCAM
|
#include <tps.h>
Inheritance diagram for cTpsKeys:Public Member Functions | |
| cTpsKeys (void) | |
| ~cTpsKeys () | |
| const cTpsKey * | GetKey (time_t t) |
| const cTpsKey * | GetV2Key (int id) |
| void | Check (time_t now, cSystem *sys) |
| cTpsKeys (void) | |
| ~cTpsKeys () | |
| const cTpsKey * | GetKey (time_t t) |
| const cTpsKey * | GetV2Key (int id) |
| void | Check (time_t now, cSystem *sys) |
Protected Member Functions | |
| virtual bool | ParseLinePlain (const char *line) |
| virtual void | PreLoad (void) |
| virtual void | PostLoad (void) |
| virtual void | PostSave (FILE *f) |
| virtual bool | ParseLinePlain (const char *line) |
| virtual void | PreLoad (void) |
| virtual void | PostLoad (void) |
| virtual void | PostSave (FILE *f) |
Friends | |
| class | cTpsAuHook |
| cTpsKeys::cTpsKeys | ( | void | ) |
Definition at line 526 of file tps.c.
:cStructListPlain<cTpsKey>("TPS keys","tps.cache",SL_READWRITE|SL_MISSINGOK|SL_WATCH|SL_NOPURGE) ,lastLoad(-LOADBIN_TIME) ,lastAu(-TPSAU_TIME) { first=last=0; algomem=0; loadlist=0; }
| cTpsKeys::~cTpsKeys | ( | ) |
| cTpsKeys::cTpsKeys | ( | void | ) |
| cTpsKeys::~cTpsKeys | ( | ) |
| void cTpsKeys::Check | ( | time_t | now, |
| cSystem * | sys | ||
| ) |
Definition at line 568 of file tps.c.
References cSystem::AddHook(), AU_STREAM, AU_TPSBIN, cScSetup::AutoUpdate, CHECK_TIME, cSimpleListBase::Count(), cTpsAuHook, cTimeMs::Elapsed(), HOOK_TPSAU, L_SYS_TPSAU, LOADBIN_TIME, cMutex::Lock(), PRINTF, cStructLoader::Purge(), ScSetup, cTimeMs::Set(), TPSAU_TIME, TPSBIN, cSystem::TriggerHook(), and cMutex::Unlock().
Referenced by cTPS::Decrypt().
{
checkMutex.Lock();
if(first==0 && last==0 && Count()>0)
GetFirstLast();
if(now>0 && lastCheck.Elapsed()>CHECK_TIME) {
Purge(now);
lastCheck.Set();
}
bool nokey=now+2*3600>last;
if(tpsAuMode==AU_TPSBIN && lastLoad.Elapsed()>(nokey ? LOADBIN_TIME/60 : LOADBIN_TIME)) {
PRINTF(L_SYS_TPSAU,"loading "TPSBIN" triggered");
LoadBin();
if(now>0) Purge(now);
lastLoad.Set();
}
if(tpsAuMode==AU_STREAM && lastAu.Elapsed()>(nokey ? TPSAU_TIME/60 : TPSAU_TIME)) {
if(ScSetup.AutoUpdate>0) {
PRINTF(L_SYS_TPSAU,"TPS AU triggered");
if(!sys->TriggerHook(HOOK_TPSAU)) {
cTpsAuHook *hook=new cTpsAuHook;
sys->AddHook(hook);
PRINTF(L_SYS_TPSAU,"TPS AU hook added");
}
}
lastAu.Set();
}
checkMutex.Unlock();
}
| void cTpsKeys::Check | ( | time_t | now, |
| cSystem * | sys | ||
| ) |
| const cTpsKey* cTpsKeys::GetKey | ( | time_t | t | ) |
| const cTpsKey * cTpsKeys::GetKey | ( | time_t | t | ) |
Definition at line 540 of file tps.c.
References cStructListPlain< cTpsKey >::First(), k, cStructLoader::ListLock(), cStructLoader::ListUnlock(), and cStructListPlain< cTpsKey >::Next().
Referenced by cTPS::Decrypt().
| const cTpsKey * cTpsKeys::GetV2Key | ( | int | id | ) |
Definition at line 549 of file tps.c.
References cPlainKeys::FindKey(), cPlainKey::Get(), keys, L_SYS_KEY, MBC3, PRINTF, and cTpsKey::Set().
Referenced by cTPS::Decrypt().
| const cTpsKey* cTpsKeys::GetV2Key | ( | int | id | ) |
| bool cTpsKeys::ParseLinePlain | ( | const char * | line | ) | [protected, virtual] |
Implements cStructLoaderPlain.
Definition at line 884 of file tps.c.
References cSimpleListBase::Add(), crc32_le(), free, GetHex(), L_SYS_TPS, MALLOC, PRINTF, cTPSDecrypt::RegisterAlgo3(), and cTpsKey::Set().
{
unsigned char tmp[60];
if(line[0]=='X') {
if(line[1]=='S') {
if(algomem) PRINTF(L_SYS_TPS,"multiple start extentions during cache load");
if(sscanf(&line[2],"%x %x %x %x",&algolen,&cb1off,&cb2off,&cb3off)==4) {
free(algomem);
if((algomem=MALLOC(unsigned char,algolen))) {
algoread=0;
return true;
}
else PRINTF(L_SYS_TPS,"no memory for algo");
}
else PRINTF(L_SYS_TPS,"bad format in start extention");
}
else if(line[1]=='C') {
if(algomem) {
int off, len;
unsigned int crc;
if(sscanf(&line[2],"%x %x %n",&off,&crc,&len)==2) {
line+=len+2;
unsigned char buff[210];
if((len=GetHex(line,buff,200,false))) {
if(crc==crc32_le(0,buff,len) && off>=0 && off+len<=algolen) {
memcpy(&algomem[off],buff,len);
algoread+=len;
if(algoread==algolen) {
RegisterAlgo3(algomem,cb1off,cb2off,cb3off,algolen);
free(algomem); algomem=0;
}
return true;
}
}
}
PRINTF(L_SYS_TPS,"bad format in code extention");
}
else PRINTF(L_SYS_TPS,"unexpected code extention");
}
else PRINTF(L_SYS_TPS,"unknown extention during cache load");
}
else {
if(GetHex(line,tmp,sizeof(tmp))) {
unsigned int crc=crc32_le(0,&tmp[4],sizeof(tmp)-4);
if(*((unsigned int *)tmp)==crc) {
cTpsKey *k=new cTpsKey;
if(k) { k->Set(&tmp[4]); if(loadlist) loadlist->Add(k); }
return true;
}
else PRINTF(L_SYS_TPS,"CRC failed during cache load");
}
}
return false;
}
| virtual bool cTpsKeys::ParseLinePlain | ( | const char * | line | ) | [protected, virtual] |
Implements cStructLoaderPlain.
| virtual void cTpsKeys::PostLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoader.
| void cTpsKeys::PostLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoader.
Definition at line 879 of file tps.c.
{
if(loadlist) { Join(loadlist); loadlist=0; }
}
| virtual void cTpsKeys::PostSave | ( | FILE * | f | ) | [protected, virtual] |
Reimplemented from cStructLoaderPlain.
| void cTpsKeys::PostSave | ( | FILE * | f | ) | [protected, virtual] |
Reimplemented from cStructLoaderPlain.
Definition at line 939 of file tps.c.
References crc32_le(), cTPSDecrypt::DumpAlgo3(), free, HexStr(), and min().
{
char str[420];
unsigned char *mem;
int len=0, cb1=0, cb2=0, cb3=0;
if((mem=DumpAlgo3(len,cb1,cb2,cb3))) {
fprintf(f,"XS %04X %04X %04X %04X\n",len,cb1,cb2,cb3);
for(int i=0; i<len; i+=200) {
int l=min(200,len-i);
fprintf(f,"XC %04X %08X %s\n",i,crc32_le(0,&mem[i],l),HexStr(str,&mem[i],l));
}
free(mem);
}
}
| virtual void cTpsKeys::PreLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoaderPlain.
| void cTpsKeys::PreLoad | ( | void | ) | [protected, virtual] |
Reimplemented from cStructLoaderPlain.
Definition at line 872 of file tps.c.
References L_SYS_TPS, and PRINTF.
{
delete loadlist;
loadlist=new cSimpleList<cTpsKey>;
if(!loadlist) PRINTF(L_SYS_TPS,"no memory for loadlist");
}
cTpsAuHook [friend] |