Ejemplo n.º 1
0
void cLogStats::Action(void)
{
  while(Running()) {
    cCondWait::SleepMs(50);
    if(sTime.Elapsed()>SAMPLE) {
      sCounts[sIdx][0]=sCount;          sCount=0;
      sCounts[sIdx][1]=sTime.Elapsed(); sTime.Set();
      if(++sIdx >= COUNTS) sIdx=0;
      }
    if(repTime.Elapsed()>REPORT) {
      repTime.Set();
      if(sCounts[(sIdx+COUNTS-1)%COUNTS][0]>0) {
        LBSTART(L_CORE_AUSTATS);
        LBPUT("EMM packet load average (%d/%d/%dmin)",AVR1/60000,AVR2/60000,AVR3/60000);
        int s=0, t=0;
        for(int i=1; i<=COUNTS; i++) {
          s+=sCounts[(sIdx+COUNTS-i)%COUNTS][0];
          t+=sCounts[(sIdx+COUNTS-i)%COUNTS][1];
          if(i==(AVR1/SAMPLE) || i==(AVR2/SAMPLE) || i==(AVR3/SAMPLE))
            LBPUT(" %4d",(int)((float)s/(float)t*1000.0));
          }
        LBPUT(" pks/s");
        LBEND();
        }
      }
    }
}
Ejemplo n.º 2
0
void cPidFilter::Start(int Pid, int Section, int Mask, int Mode, bool Crc)
{
  cMutexLock lock(this);
  if(fd>=0) {
    Stop();
    struct dmx_sct_filter_params FilterParams;
    memset(&FilterParams,0,sizeof(FilterParams));
    FilterParams.filter.filter[0]=Section;
    FilterParams.filter.mask[0]=Mask;
    FilterParams.filter.mode[0]=Mode;
    FilterParams.flags=DMX_IMMEDIATE_START;
    if(Crc) FilterParams.flags|=DMX_CHECK_CRC;
    FilterParams.pid=Pid;
    if(ioctl(fd,DMX_SET_FILTER,&FilterParams)<0) {
      PRINTF(L_GEN_ERROR,"filter '%s': DMX_SET_FILTER failed: %s",id,strerror(errno));
      return;
      }
    pid=Pid;
    active=true;

    LBSTART(L_CORE_ACTION);
    LBPUT("filter '%s' -> pid=0x%04x sct=0x%02x/0x%02x/0x%02x crc=%d matching",id,Pid,Section,Mask,Mode,Crc);
    int mam =Mask &  (~Mode);
    int manm=Mask & ~(~Mode);
    for(int i=0; i<256; i++) {
      int xxxor=Section ^ i;
      if((mam&xxxor) || (manm && !(manm&xxxor))) {}
      else
        LBPUT(" 0x%02x",i);
      }
    LBEND();
    }
}
Ejemplo n.º 3
0
bool cCardClient::ParseStdConfig(const char *config, int *num)
{
  int n, emm=0;
  if(!num) num=&n;
  if(sscanf(config,"%63[^:]:%d:%d%n",hostname,&port,&emm,num)<3) return false;
  if(emm>0) emmAllowed=1;
  if(emm==2) emmAllowed=2; // EMM caching disabled
  if(config[*num]=='/') {
    numCaid=0;
    do {
      emmMask[numCaid]=0xFFFF;
      int start=(*num)+1;
      if(sscanf(&config[start],"%x%n/%x%n",&emmCaid[numCaid],num,&emmMask[numCaid],num)<1)
        return false;
      *num+=start;
      if(emmMask[numCaid]==0x0000 && emmCaid[numCaid]!=0x0000)
        PRINTF(L_GEN_WARN,"CAID %04x MASK %04x in cardclient config doesn't match anything!",emmCaid[numCaid],emmMask[numCaid]);
      numCaid++;
      } while(numCaid<MAX_CC_CAID && config[*num]==',');
    }
  LBSTART(L_CC_CORE);
  LBPUT("hostname=%s port=%d emm=%d emmCaids",hostname,port,emmAllowed);
  for(int i=0; i<numCaid; i++) LBPUT(" %04x/%04x",emmCaid[i],emmMask[i]);
  LBEND();
  return true;
}
Ejemplo n.º 4
0
void cOverrideEmmTable::AddPids(cPids *pids, int pid, int caid)
{
  LBSTARTF(L_CORE_OVER);
  LBPUT("emmtable: %04x:",caid);
  for(int i=0; i<num; i++) {
    LBPUT(" %02x/%02x",table[i],mask[i]);
    pids->AddPid(pid,table[i],mask[i]);
    }
  LBEND();
}
Ejemplo n.º 5
0
bool cCardClientRadegast::Login(void)
{
  Logout();
  if(!so.Connect(hostname,port)) return false;
  PRINTF(L_CC_LOGIN,"%s: connected to %s:%d",name,hostname,port);

  InitVars();
  unsigned char buff[512];
  char hello[32];
  snprintf(hello,sizeof(hello),"rdgd/vdr-sc-%s",ScVersion);
  StartMsg(buff,0x90);			// RDGD_MSG_CLIENT_HELLO
  AddNano(buff,1,strlen(hello),(unsigned char *)hello);	// RDGD_NANO_DESCR
  if(!Send(buff) || Recv(buff,sizeof(buff))<0) return false;
  if(buff[0]==0x91) {
    PRINTF(L_CC_RDGD,"got server hello, assuming V4 mode");
    StartMsg(buff,0x94);		// RDGD_MSG_CLIENT_CAP_REQ;
    int n;
    if(!Send(buff) || (n=Recv(buff,sizeof(buff)))<0) return false;
    if(buff[0]==0x95) {
      LBSTARTF(L_CC_LOGIN);
      LBPUT("radegast: got caps");
      int caid;
      for(int l=GetNanoStart(buff); l<n; l+=buff[l+1]+2) {
        switch(buff[l]) {
          case 0xE2:
            LBPUT(" VERS %s",(char *)&buff[l+2]);
            break;
          case 0xE4: // CAP_NANO_CAID
            if(numCaids>=MAXCAIDS) { l=n; break; } //stop processing
            caid=(buff[l+2]<<8)+buff[l+3];
            LBPUT(" CAID %04X",caid);
            caids[numCaids++]=caid;
            // XXX we should have EMM processing setup here, but as we don't
            // XXX get any ua/sa we cannot filter EMM anyways
            break;
          case 0xE5: // CAP_NANO_PROVID
            for(int i=0; i<buff[l+1]; i+=3)
              LBPUT("/%02X%02X%02X",buff[l+2+i],buff[l+2+i+1],buff[l+2+i+2]);
            break;
          }
        }
      LBEND();
      }
    }
  else PRINTF(L_CC_RDGD,"no server hello, assuming old mode");
  if(emmProcessing && !emmAllowed) 
    PRINTF(L_CC_EMM,"%s: EMM disabled from config",name);
  CaidsChanged();
  return true;
}
Ejemplo n.º 6
0
void cScSetup::Check(void)
{
  if(AutoUpdate==0)
    PRINTF(L_GEN_WARN,"Keys updates (AU) are disabled.");
  for(int i=0; i<MAXSCCAPS; i++)
    if(ScCaps[i]>=16) {
      PRINTF(L_GEN_WARN,"ScCaps contains unusual value. Check your config! (You can ignore this message if you have more than 16 dvb cards in your system ;)");
      break;
      }

  PRINTF(L_CORE_LOAD,"** Key updates (AU) are %s (%sprestart)",AutoUpdate?(AutoUpdate==1?"enabled (active CAIDs)":"enabled (all CAIDs)"):"DISABLED",PrestartAU?"":"no ");
  PRINTF(L_CORE_LOAD,"** Local systems %stake priority over cached remote",LocalPriority?"":"DON'T ");
  PRINTF(L_CORE_LOAD,"** %sorce transfermode with digital audio",ForceTransfer?"F":"DON'T f");
  PRINTF(L_CORE_LOAD,"** ECM cache is set to %s",EcmCache ? (EcmCache==1?"READ-ONLY":"DISABLED"):"enabled");
  PRINTF(L_CORE_LOAD,"** TsBufferSize is %d MB",DeCsaTsBuffSize);
  LBSTART(L_CORE_LOAD);
  LBPUT("** ScCaps are"); for(int i=0; i<MAXSCCAPS ; i++) LBPUT(" %d",ScCaps[i]);
  LBEND();
}
Ejemplo n.º 7
0
bool cOverrideEmmTable::Parse(char *str)
{
  if((str=Parse3(str))) {
    num=0;
    int n=-1;
    do {
      mask[num]=0xFF;
      int l=n+1;
      if(sscanf(&str[l],"%x%n/%x%n",&table[num],&n,&mask[num],&n)<1) {
        PRINTF(L_CORE_LOAD,"override: EMMTABLE format error");
        return false;
        }
      n+=l; num++;
      } while(num<OV_MAXTABLES && str[n]==':');
    LBSTART(L_CORE_OVER);
    LBPUT("emmtable: %s - tables",*Print());
    for(int i=0; i<num; i++) LBPUT(" %02x/%02x",table[i],mask[i]);
    LBEND();
    return true;
    }
  return false;
}
Ejemplo n.º 8
0
void cPidFilter::Start(int Pid, int Section, int Mask)
{
  cMutexLock lock(this);
  Stop();
  fd=device->OpenFilter(Pid,Section,Mask);
  if(fd>=0) {
    pid=Pid;

    LBSTART(L_CORE_ACTION);
    LBPUT("filter '%s' -> pid=0x%04x sct=0x%02x/0x%02x matching",id,Pid,Section,Mask);
    int Mode=0;
    int mam =Mask &  (~Mode);
    int manm=Mask & ~(~Mode);
    for(int i=0; i<256; i++) {
      int xxxor=Section ^ i;
      if((mam&xxxor) || (manm && !(manm&xxxor))) {}
      else
        LBPUT(" 0x%02x",i);
      }
    LBEND();
    }
}
Ejemplo n.º 9
0
bool cLogChain::Parse(const unsigned char *cat)
{
  if(cat[0]==0x09) {
    caid=WORD(cat,2,0xFFFF);
    LBSTARTF(L_CORE_AU);
    LBPUT("%d: chain caid %04x",cardNum,caid);
    cSystem *sys;
    if(systems.Count()>0) {
      LBPUT(" ++");
      for(sys=systems.First(); sys; sys=systems.Next(sys))
        sys->ParseCAT(&pids,cat,source,transponder);
      }
    else {
      LBPUT(" ->");
      if(!overrides.Ignore(source,transponder,caid)) {
        int Pri=0;
        while((sys=cSystems::FindBySysId(caid,!softCSA,Pri))) {
          Pri=sys->Pri();
          if(sys->HasLogger()) {
            sys->CardNum(cardNum);
            sys->ParseCAT(&pids,cat,source,transponder);
            systems.Add(sys);
            LBPUT(" %s(%d)",sys->Name(),sys->Pri());
            }
          else
            delete sys;
          }
        }
      }
    if(systems.Count()==0) LBPUT(" none available");
    for(cPid *pid=pids.First(); pid; pid=pids.Next(pid))
       LBPUT(" [%04x-%02x/%02x/%02x]",pid->pid,pid->sct,pid->mask,pid->mode);
    LBEND();
    if(systems.Count()>0 && pids.Count()>0)
      return true;
    }
  return false;
}