#ifndef ___SYSTEM_H
#define ___SYSTEM_H
-#include <stdio.h>
-#include <ctype.h>
-
#include <vdr/tools.h>
#include "data.h"
#include "misc.h"
-#include "log-core.h"
-#include "i18n.h"
// ----------------------------------------------------------------
// ----------------------------------------------------------------
-template<class T> class cCardInfos : public cSimpleList<T>, public cLoader, cConfRead {
-private:
- const char *sysname;
-public:
- cCardInfos(const char *id):cLoader(id) {}
- virtual ~cCardInfos() {}
- bool HaveCards(void) { return (this->Count()!=0); }
- bool Load(const char *cfgdir, const char *SysName, const char *kidName)
- {
- sysname=SysName;
- this->Clear();
- char type[32];
- snprintf(type,sizeof(type),"%s card infos",SysName);
- cString cname=AddDirectory(cfgdir,kidName);
- ConfRead(type,cname,true);
- PRINTF(L_CORE_LOAD,"loaded %d %s cards from %s",this->Count(),SysName,*cname);
- return HaveCards();
- }
- virtual bool ParseLine(const char *line, bool fromCache)
- {
- T *k=new T;
- if(k) {
- if(k->Parse((char *)line)) {
- if(!fromCache) { Add(k); k=0; }
- else {
- T *o=this->First();
- while(o) {
- if(o->Cmp(k)) {
- Add(k,o); k->Updated(); k=0;
- Del(o);
- break;
- }
- o=this->Next(o);
- }
- }
- }
- delete k;
- return true;
- }
- PRINTF(L_GEN_ERROR,"not enough memory for %s card infos!",sysname);
- return false;
- }
- virtual bool Save(FILE *f)
- {
- bool res=true;
- T *k=this->First();
- while(k) {
- if(k->IsUpdated() && !k->Save(f)) { res=false; break; }
- k=this->Next(k);
- }
- Modified(!res);
- return res;
- }
- };
-
-// ----------------------------------------------------------------
-
struct Cache;
class cMsgCache {
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
-#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "system-common.h"
// -- cIrdCardInfo -------------------------------------------------------------
-class cIrdCardInfo : public cProviderIrdeto, public cCardIrdeto {
-private:
- bool updated;
+class cIrdCardInfo : public cStructItem, public cProviderIrdeto, public cCardIrdeto {
public:
unsigned char PMK[8], HMK[10];
bool haveHMK;
//
- cIrdCardInfo(void);
bool Parse(const char *line);
- bool Save(FILE *f);
- bool Update(unsigned char *pmk, unsigned char *id);
- bool IsUpdated(void) { return updated; }
- void Updated(void) { updated=true; }
- bool Cmp(cIrdCardInfo *ci);
+ virtual cString ToString(bool hide=false);
};
-cIrdCardInfo::cIrdCardInfo(void)
-{
- updated=false;
-}
-
bool cIrdCardInfo::Parse(const char *line)
{
haveHMK=false;
GetHex(line,PMK,sizeof(PMK));
}
-bool cIrdCardInfo::Save(FILE *f)
+cString cIrdCardInfo::ToString(bool hide)
{
char s1[20], s2[20], s3[20], s4[20];
- fprintf(f,"%s %s %02x %s %s\n",
+ return cString::sprintf("%s %s %02x %s %s",
HexStr(s1,hexSer,sizeof(hexSer)),HexStr(s2,HMK,sizeof(HMK)),provBase,
HexStr(s3,provId,sizeof(provId)),HexStr(s4,PMK,sizeof(PMK)));
- return ferror(f)==0;
-}
-
-bool cIrdCardInfo::Cmp(cIrdCardInfo *ci)
-{
- return (!memcmp(hexSer,ci->hexSer,sizeof(hexSer)) &&
- !memcmp(HMK,ci->HMK,sizeof(HMK)));
-}
-
-bool cIrdCardInfo::Update(unsigned char *pmk, unsigned char *id)
-{
- bool res=false;
- char str[20], str2[12];
- if(memcmp(PMK,pmk,sizeof(PMK))) {
- PRINTF(L_GEN_INFO,"new PMK for I card %s: %s",HexStr(str2,hexSer,sizeof(hexSer)),KeyStr(str,pmk));
- memcpy(PMK,pmk,sizeof(PMK));
- Updated(); res=true;
- }
- if(id && memcmp(provId,id,sizeof(provId))) {
- PRINTF(L_GEN_INFO,"new PrvID for I card %s: %s",HexStr(str2,hexSer,sizeof(hexSer)),HexStr(str,id,sizeof(provId)));
- memcpy(provId,id,sizeof(provId));
- Updated(); res=true;
- }
- return res;
}
// -- cIrdCardInfos ------------------------------------------------------------
class cIrdCardInfos : public cCardInfos<cIrdCardInfo> {
public:
- cIrdCardInfos(void):cCardInfos<cIrdCardInfo>(SYSTEM_NAME) {}
- bool Update(cIrdCardInfo *ci, unsigned char *pmk, unsigned char *id);
+ cIrdCardInfos(void);
+ bool Update(cIrdCardInfo *ci, const unsigned char *pmk, const unsigned char *id);
};
static cIrdCardInfos Icards;
-bool cIrdCardInfos::Update(cIrdCardInfo *ci, unsigned char *pmk, unsigned char *id)
+cIrdCardInfos::cIrdCardInfos(void)
+:cCardInfos<cIrdCardInfo>("Irdeto cards","Ird-Beta.KID",true)
+{}
+
+bool cIrdCardInfos::Update(cIrdCardInfo *ci, const unsigned char *pmk, const unsigned char *id)
{
- bool res=ci->Update(pmk,id);
+ bool res=false;
+ char str[20], str2[12];
+ if(memcmp(ci->PMK,pmk,sizeof(ci->PMK))) {
+ PRINTF(L_GEN_INFO,"new PMK for I card %s: %s",HexStr(str2,ci->hexSer,sizeof(ci->hexSer)),KeyStr(str,pmk));
+ memcpy(ci->PMK,pmk,sizeof(ci->PMK));
+ res=true;
+ }
+ if(id && memcmp(ci->provId,id,sizeof(ci->provId))) {
+ PRINTF(L_GEN_INFO,"new PrvID for I card %s: %s",HexStr(str2,ci->hexSer,sizeof(ci->hexSer)),HexStr(str,id,sizeof(ci->provId)));
+ memcpy(ci->provId,id,sizeof(ci->provId));
+ res=true;
+ }
if(res) Modified();
return res;
}
cSystemLinkIrd(void);
virtual bool CanHandle(unsigned short SysId);
virtual cSystem *Create(void) { return new cSystemIrd; }
- virtual bool Init(const char *cfgdir);
};
static cSystemLinkIrd staticInit;
SysId&=SYSTEM_MASK;
return SYSTEM_CAN_HANDLE(SysId);
}
-
-bool cSystemLinkIrd::Init(const char *cfgdir)
-{
- Icards.Load(cfgdir,SYSTEM_NAME,"Ird-Beta.KID");
- return true;
-}
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
// -- cSecaCardInfo ------------------------------------------------------------
-class cSecaCardInfo : public cProviderSeca {
+class cSecaCardInfo : public cStructItem, public cProviderSeca {
private:
int len;
public:
unsigned char key[16];
//
bool Parse(const char *line);
- bool Save(FILE *f) { return true; }
- bool IsUpdated(void) { return false; }
- void Updated(void) {}
- bool Cmp(cSecaCardInfo *ci) { return false; }
+ virtual cString ToString(bool hide=false) { return ""; }
int KeySize(void) { return len; }
};
class cSecaCardInfos : public cCardInfos<cSecaCardInfo> {
public:
- cSecaCardInfos(void):cCardInfos<cSecaCardInfo>(SYSTEM_NAME) {}
+ cSecaCardInfos(void):cCardInfos<cSecaCardInfo>("Seca cards","Seca.KID",false) {}
};
static cSecaCardInfos Scards;
cSystemLinkSeca(void);
virtual bool CanHandle(unsigned short SysId);
virtual cSystem *Create(void) { return new cSystemSeca; }
- virtual bool Init(const char *cfgdir);
};
static cSystemLinkSeca staticInit;
SysId&=SYSTEM_MASK;
return SYSTEM_CAN_HANDLE(SysId);
}
-
-bool cSystemLinkSeca::Init(const char *cfgdir)
-{
- Scards.Load(cfgdir,SYSTEM_NAME,"Seca.KID");
- return true;
-}
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*/
-#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
-#include "viaccess.h"
-#include "tps.h"
#include "system-common.h"
#include "misc.h"
#include "parse.h"
+#include "log-core.h"
+
+#include "viaccess.h"
+#include "tps.h"
#include "log-viaccess.h"
#define SYSTEM_NAME "Viaccess"
// -- cViaccessCardInfo --------------------------------------------------------
-class cViaccessCardInfo : public cProviderViaccess, public cCardViaccess {
+class cViaccessCardInfo : public cStructItem, public cProviderViaccess, public cCardViaccess {
public:
unsigned char keyno, key[8];
//
bool Parse(const char *line);
- bool Save(FILE *f) { return true; }
- bool IsUpdated(void) { return false; }
- void Updated(void) {}
- bool Cmp(cViaccessCardInfo *ci) { return false; }
+ virtual cString ToString(bool hide=false) { return ""; }
};
bool cViaccessCardInfo::Parse(const char *line)
class cViaccessCardInfos : public cCardInfos<cViaccessCardInfo> {
public:
- cViaccessCardInfos(void):cCardInfos<cViaccessCardInfo>(SYSTEM_NAME) {}
+ cViaccessCardInfos(void):cCardInfos<cViaccessCardInfo>("Viaccess cards","Viaccess.KID",false) {}
};
static cViaccessCardInfos Vcards;
cSystemLinkViaccess(void);
virtual bool CanHandle(unsigned short SysId);
virtual cSystem *Create(void) { return new cSystemViaccess; }
- virtual bool Init(const char *cfgdir);
};
static cSystemLinkViaccess staticInit;
SysId&=SYSTEM_MASK;
return SYSTEM_CAN_HANDLE(SysId);
}
-
-bool cSystemLinkViaccess::Init(const char *cfgdir)
-{
- Vcards.Load(cfgdir,SYSTEM_NAME,"Viaccess.KID");
- return true;
-}