SASC-NG
DVBSoftCAM

cSystem Class Reference

#include <system.h>

Inheritance diagram for cSystem:

List of all members.

Public Member Functions

 cSystem (const char *Name, int Pri)
virtual ~cSystem ()
void SetOwner (cCam *Cam)
virtual int CheckECM (const cEcmInfo *ecm, const unsigned char *data, bool sync)
virtual void CheckECMResult (const cEcmInfo *ecm, const unsigned char *data, bool result)
virtual bool ProcessECM (const cEcmInfo *ecm, unsigned char *buffer)=0
virtual void ProcessEMM (int pid, int caid, const unsigned char *buffer)
virtual void ParseCADescriptor (cSimpleList< cEcmInfo > *ecms, unsigned short sysId, int source, const unsigned char *data, int len)
virtual void ParseCAT (cPids *pids, const unsigned char *buffer, int source, int transponder)
void AddHook (cLogHook *hook)
bool TriggerHook (int id)
unsigned char * CW (void)
void DoLog (bool Log)
int Pri (void)
const char * CurrentKeyStr (void)
const char * Name (void)
int MaxEcmTry (void)
bool HasLogger (void)
bool NeedsLogger (void)
bool Local (void)
bool NeedsData (void)
bool Constant (void)

Static Public Member Functions

static void CaidsChanged (void)
static void FoundKey (void)
static void NewKey (void)
static void KeyStats (int &fk, int &nk)

Protected Member Functions

void KeyOK (cPlainKey *pk)
void KeyOK (const char *txt)
void KeyFail (int type, int id, int keynr)
void StartLog (const cEcmInfo *ecm, int caid)

Protected Attributes

const char * name
unsigned char cw [16]
bool doLog
int maxEcmTry
bool local
bool hasLogger
bool needsLogger
bool needsDescrData
bool constant

Friends

class cKeySnoop

Detailed Description

Definition at line 93 of file system.h.


Constructor & Destructor Documentation

cSystem::cSystem ( const char *  Name,
int  Pri 
)

Definition at line 99 of file system.c.

References constant, cw, doLog, hasLogger, local, maxEcmTry, Name(), name, needsDescrData, needsLogger, and Pri().

{
  name=Name; pri=Pri;
  currentKeyStr[0]=0; doLog=true; cam=0; logecm=0;
  check=new struct EcmCheck;
  memset(check,0,sizeof(struct EcmCheck));
  memset(cw,0,sizeof(cw));
  // default config
  maxEcmTry=2; // try to get a key X times from the same ECM pid (default)
  hasLogger=false;
  needsLogger=false;
  local=true;
  needsDescrData=false;
  constant=false;
}
cSystem::~cSystem ( ) [virtual]

Definition at line 115 of file system.c.

References cCam::LogEcmStatus().

{
  delete check;
  if(logecm && cam) cam->LogEcmStatus(logecm,false);
  delete logecm;
}

Member Function Documentation

void cSystem::AddHook ( cLogHook *  hook)

Definition at line 133 of file system.c.

References cCam::AddHook().

Referenced by cTpsKeys::Check(), and cSatTime::Now().

{
  if(cam) cam->AddHook(hook);
}
void cSystem::CaidsChanged ( void  ) [static]

Definition at line 143 of file system.c.

int cSystem::CheckECM ( const cEcmInfo *  ecm,
const unsigned char *  data,
bool  sync 
) [virtual]

Definition at line 202 of file system.c.

References EcmCheck::caid, cEcmInfo::caId, L_CORE_ECMPROC, name, PRINTF, EcmCheck::sys06, and WORD.

Referenced by cEcmHandler::Process().

{
  switch(ecm->caId>>8) {
    case 0x06: // Irdeto
      {
      const int chid=WORD(data,6,0xFFFF);
      // if multiple channel id's, use current one only
      if(sync && check->caid.sys06.current>0 && chid!=check->caid.sys06.current) {
        PRINTF(L_CORE_ECMPROC,"ecmcheck(%s): chid %04x != current %04x",name,chid,check->caid.sys06.current);
        return 3;
        }
/*
//XXX is that still needed? Seems to conflict with some Irdeto2 provider
      // search for fake channel id's on Stream
      const int cur=data[4];
      const int max=data[5];
      if(!sync && max>0 && max<MAX_CHID) {
        if(cur==0) check->caid.sys06.startFlag=true;
        if(check->caid.sys06.startFlag) {
          if(cur<=max) check->caid.sys06.chids[cur]=chid;
          if(cur==max) {
            for(int i=0 ; i<max ; i++) {
              if(check->caid.sys06.chids[i]==0) {
                check->caid.sys06.startFlag=false;
                PRINTF(L_CORE_ECMPROC,"ecmcheck(%s): zero chid",name);
                return 1;
                }
              for(int j=i+1 ; j<=max ; j++) {
                if(check->caid.sys06.chids[i]==check->caid.sys06.chids[j]) {
                  check->caid.sys06.startFlag=false;
                  PRINTF(L_CORE_ECMPROC,"ecmcheck(%s): duplicate chid %04x",name,check->caid.sys06.chids[i]);
                  return 1;
                  }
                }
              }
            }
          }
        }
*/
      break;
      }
    }
  return 0;
}
void cSystem::CheckECMResult ( const cEcmInfo *  ecm,
const unsigned char *  data,
bool  result 
) [virtual]

Definition at line 247 of file system.c.

References EcmCheck::caid, cEcmInfo::caId, EcmCheck::sys06, and WORD.

Referenced by cEcmHandler::Process().

{
  switch(ecm->caId>>8) {
    case 0x06: // Irdeto
      check->caid.sys06.current=result ? WORD(data,6,0xFFFF) : 0;
      break;
    }
}
bool cSystem::Constant ( void  ) [inline]

Definition at line 142 of file system.h.

References constant.

Referenced by cEcmHandler::Process().

{ return constant; }
const char* cSystem::CurrentKeyStr ( void  ) [inline]

Definition at line 135 of file system.h.

Referenced by cEcmHandler::CurrentKeyStr().

{ return currentKeyStr; }
unsigned char* cSystem::CW ( void  ) [inline]

Definition at line 132 of file system.h.

References cw.

Referenced by main(), and cEcmHandler::Process().

{ return cw; }
void cSystem::DoLog ( bool  Log) [inline]

Definition at line 133 of file system.h.

References doLog.

Referenced by main(), and cEcmHandler::Process().

{ doLog=Log; }
static void cSystem::FoundKey ( void  ) [inline, static]
bool cSystem::HasLogger ( void  ) [inline]

Definition at line 138 of file system.h.

References hasLogger.

Referenced by main(), and cLogChain::Parse().

{ return hasLogger; }
void cSystem::KeyFail ( int  type,
int  id,
int  keynr 
) [protected]

Definition at line 271 of file system.c.

References doLog, keys, cPlainKeys::KeyString(), L_CORE_ECM, cLastKey::NotLast(), PRINTF, and cPlainKeys::Trigger().

Referenced by cKeySnoop::~cKeySnoop().

{
  keys.Trigger(type,id,keynr);
  if(lastkey.NotLast(type,id,keynr) && doLog)
    PRINTF(L_CORE_ECM,"system: no key found for %s",*keys.KeyString(type,id,keynr));
}
void cSystem::KeyOK ( const char *  txt) [protected]

Definition at line 265 of file system.c.

References doLog, name, and tr.

{
  snprintf(currentKeyStr,sizeof(currentKeyStr),"%s (%s)\n",txt?txt:name,tr("undisclosed key"));
  doLog=true;
}
void cSystem::KeyOK ( cPlainKey *  pk) [protected]

Definition at line 256 of file system.c.

References doLog, cPlainKey::id, cPlainKey::keynr, L_CORE_ECM, cLastKey::NotLast(), PRINTF, strn0cpy(), cPlainKey::ToString(), and cPlainKey::type.

Referenced by cKeySnoop::OK(), cSystemCardClient::ProcessECM(), and cSystemScCore::ProcessECM().

{
  if(lastkey.NotLast(pk->type,pk->id,pk->keynr)) {
    strn0cpy(currentKeyStr,pk->ToString(false),sizeof(currentKeyStr));
    PRINTF(L_CORE_ECM,"system: using key %s",*pk->ToString(true));
    doLog=true;
    }
}
static void cSystem::KeyStats ( int &  fk,
int &  nk 
) [inline, static]

Definition at line 146 of file system.h.

Referenced by cMenuInfoSc::cMenuInfoSc().

{ fk=foundKeys; nk=newKeys; }
bool cSystem::Local ( void  ) [inline]

Definition at line 140 of file system.h.

References local.

{ return local; }
int cSystem::MaxEcmTry ( void  ) [inline]

Definition at line 137 of file system.h.

References maxEcmTry.

Referenced by cEcmHandler::Process().

{ return maxEcmTry; }
const char* cSystem::Name ( void  ) [inline]

Definition at line 136 of file system.h.

References name.

Referenced by cSystem(), main(), cLogChain::Parse(), and cEcmHandler::Process().

{ return name; }
bool cSystem::NeedsData ( void  ) [inline]

Definition at line 141 of file system.h.

References needsDescrData.

Referenced by cEcmHandler::Process().

{ return needsDescrData; }
bool cSystem::NeedsLogger ( void  ) [inline]

Definition at line 139 of file system.h.

References needsLogger.

{ return needsLogger; }
static void cSystem::NewKey ( void  ) [inline, static]
void cSystem::ParseCADescriptor ( cSimpleList< cEcmInfo > *  ecms,
unsigned short  sysId,
int  source,
const unsigned char *  data,
int  len 
) [virtual]

Reimplemented in cSystemScViaccess, and cSystemViaccess.

Definition at line 148 of file system.c.

References cSimpleListBase::Add(), name, cEcmInfo::SetDataIdx(), and WORD.

{
  const int pid=WORD(data,2,0x1FFF);
  switch(sysId>>8) {
    case 0x01: // Seca style
      for(int p=2; p<len; p+=15) {
        cEcmInfo *n=new cEcmInfo(name,WORD(data,p,0x1FFF),sysId,WORD(data,p+2,0xFFFF));
        if(data[p+4]==0xFF) n->SetDataIdx(p+5);
        ecms->Add(n);
        }
      break;
    case 0x05: // Viaccess style
      for(int p=4; p<len; p+=2+data[p+1])
        if(data[p]==0x14)
          ecms->Add(new cEcmInfo(name,pid,sysId,(data[p+2]<<16)|(data[p+3]<<8)|(data[p+4]&0xF0)));
      break;
    default:   // default style
      ecms->Add(new cEcmInfo(name,pid,sysId,0));
      break;
    }
}
void cSystem::ParseCAT ( cPids *  pids,
const unsigned char *  buffer,
int  source,
int  transponder 
) [virtual]

Definition at line 170 of file system.c.

References cOverrides::AddEmmPids(), cPids::AddPid(), caid, i, overrides, and WORD.

Referenced by cLogChain::Parse().

{
  if(buffer[0]==0x09) {
    int caid=WORD(buffer,2,0xFFFF);
    int pid=WORD(buffer,4,0x1FFF);
    if(overrides.AddEmmPids(caid,source,transponder,pids,pid)) return;
    switch(caid>>8) {
      case 0x01: // Seca style (82/84)
        if(buffer[1]>4) {
          pids->AddPid(pid,0x82,0xFF); // Unique updates
          for(int i=7, nn=buffer[6] ; nn ; nn--,i+=4)
            pids->AddPid(WORD(buffer,i,0x1FFF),0x84,0xFF); // Shared updates
          }
        break;
      case 0x05: // Viaccess style (88/8c/8d/8e)
        pids->AddPid(pid,0x88,0xF9); // mismatching 8a
        pids->AddPid(pid,0x8D,0xFF);
        break;
      case 0x0d: // Cryptoworks style (82/84/86/88/89)
        pids->AddPid(pid,0x82,0xF9); // mismatching 80
        pids->AddPid(pid,0x88,0xFE);
        break;
      case 0x18: // Nagra style (82/83)
        pids->AddPid(pid,0x82,0xFE);
        break;
      default:   // default style (82)
        pids->AddPid(pid,0x82,0xFF);
        break;
      }
    }
}
int cSystem::Pri ( void  ) [inline]

Definition at line 134 of file system.h.

Referenced by cSystem(), main(), and cLogChain::Parse().

{ return pri; }
virtual bool cSystem::ProcessECM ( const cEcmInfo *  ecm,
unsigned char *  buffer 
) [pure virtual]
virtual void cSystem::ProcessEMM ( int  pid,
int  caid,
const unsigned char *  buffer 
) [inline, virtual]

Reimplemented in cSystemScCore, cSystemCardClient, cSystemIrd, cSystemIrd2, cSystemNagra, cSystemNagra2, cSystemSeca, and cSystemViaccess.

Definition at line 125 of file system.h.

Referenced by main().

{};
void cSystem::SetOwner ( cCam *  Cam) [inline]

Definition at line 119 of file system.h.

Referenced by cLogChain::Parse().

{ cam=Cam; }
void cSystem::StartLog ( const cEcmInfo *  ecm,
int  caid 
) [protected]

Definition at line 122 of file system.c.

References caid, cEcmInfo::caId, cEcmInfo::emmCaId, and cCam::LogEcmStatus().

Referenced by cSystemNagra2::ProcessECM().

{
  if(!logecm || logecm->caId!=caid) {
    if(logecm && cam) cam->LogEcmStatus(logecm,false);
    delete logecm;
    logecm=new cEcmInfo(ecm);
    logecm->caId=caid; logecm->emmCaId=0;
    if(cam) cam->LogEcmStatus(logecm,true);
    }
}
bool cSystem::TriggerHook ( int  id)

Definition at line 138 of file system.c.

References cCam::TriggerHook().

Referenced by cTpsKeys::Check(), and cSatTime::Now().

{
  return cam && cam->TriggerHook(id);
}

Friends And Related Function Documentation

friend class cKeySnoop [friend]

Definition at line 94 of file system.h.


Member Data Documentation

bool cSystem::constant [protected]

Definition at line 110 of file system.h.

Referenced by Constant(), cSystem(), and cSystemConstCw::cSystemConstCw().

bool cSystem::local [protected]

Definition at line 110 of file system.h.

Referenced by cSystem(), cSystemCardClient::cSystemCardClient(), and Local().

int cSystem::maxEcmTry [protected]

Definition at line 109 of file system.h.

Referenced by cSystem(), MaxEcmTry(), and cSystemViaccess::ProcessECM().

const char* cSystem::name [protected]

Definition at line 105 of file system.h.

Referenced by CheckECM(), cSystem(), KeyOK(), Name(), and ParseCADescriptor().

bool cSystem::needsDescrData [protected]

Definition at line 110 of file system.h.

Referenced by cSystem(), cSystemScSeca::cSystemScSeca(), and NeedsData().

bool cSystem::needsLogger [protected]

Definition at line 110 of file system.h.

Referenced by cSystem(), and NeedsLogger().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines