SASC
DVBSoftCAM

cParseNDS Class Reference

#include <parse.h>

List of all members.

Static Public Member Functions

static unsigned int NumAddr (const unsigned char *data)
static int AddrMode (const unsigned char *data)
static bool IsSA (const unsigned char *data)
static bool HasAddr (const unsigned char *data, const unsigned char *a)
static const unsigned char * PayloadStart (const unsigned char *data, const unsigned char *a)
static int PayloadSize (const unsigned char *data, const unsigned char *a)
static int Assemble (cAssembleData *ad, const unsigned char *a)
static unsigned int NumAddr (const unsigned char *data)
static int AddrMode (const unsigned char *data)
static bool IsSA (const unsigned char *data)
static bool HasAddr (const unsigned char *data, const unsigned char *a)
static const unsigned char * PayloadStart (const unsigned char *data, const unsigned char *a)
static int PayloadSize (const unsigned char *data, const unsigned char *a)
static int Assemble (cAssembleData *ad, const unsigned char *a)

Detailed Description

Definition at line 303 of file parse.h.


Member Function Documentation

int cParseNDS::AddrMode ( const unsigned char *  data) [static]

Definition at line 726 of file parse.c.

Referenced by Assemble(), HasAddr(), PayloadSize(), and PayloadStart().

{
  switch(data[3]&0xC0) {
    case 0x40: return 3;
    case 0x80: return 2;
    default:   return 0;
    }
}
static int cParseNDS::AddrMode ( const unsigned char *  data) [static]
int cParseNDS::Assemble ( cAssembleData *  ad,
const unsigned char *  a 
) [static]

Definition at line 784 of file parse.c.

References AddrMode(), cAssembleData::Data(), data, i, NumAddr(), PayloadSize(), PayloadStart(), cAssembleData::SetAssembled(), and SetSctLen().

{
  const unsigned char *data=ad->Data();
  int len=cParseNDS::PayloadSize(data,a);
  const unsigned char *pl=cParseNDS::PayloadStart(data,a);
  switch(cParseNDS::AddrMode(data)) {
    case 0:
     {
     int n=*(pl-1) & 0x01;
     for(int i=cParseNDS::NumAddr(data); i>0 && len>0; i--) {
       int l;
       if(n) { 
         l=(((*pl & 0x3F)<<8) + *(pl+1)) << 1;
         pl+=2; len-=2;
         }
       else {
         l=(*pl & 0x3F) << 1;
         pl++; len--;
         }
       if(l>0 && l<=len) {
         unsigned char *ass=(unsigned char *)malloc(len+4); if(!ass) return -1; // ignore
         ass[0]=data[0];
         ass[3]=data[3]&0x0F;
         memcpy(&ass[4],pl,l);
         SetSctLen(ass,l+1);
         ad->SetAssembled(ass);
         pl+=l; len-=l;
         }
       }
     return 1; // assembled
     }

    case 2:
    case 3:
      {
      unsigned char *ass=(unsigned char *)malloc(len+3+8); if(!ass) return -1; // ignore
      ass[0]=data[0];
      ass[3]=data[3]&0xCF;
      memcpy(&ass[4],a,4);
      memcpy(&ass[8],pl,len+3);
      SetSctLen(ass,len+3+5);
      ad->SetAssembled(ass);
      return 1; // assembled
      }
    }
  return -1; // ignore
}
static int cParseNDS::Assemble ( cAssembleData *  ad,
const unsigned char *  a 
) [static]
bool cParseNDS::HasAddr ( const unsigned char *  data,
const unsigned char *  a 
) [static]

Definition at line 735 of file parse.c.

References AddrMode(), and NumAddr().

Referenced by cCardNDS::MatchEMM(), and cProviderNDS::MatchEMM().

{
  int s;
  switch(AddrMode(data)) {
    case 2: s=3; break;
    case 3: s=4; break;
    default: return true;
    }
  for(int l=NumAddr(data)-1; l>=0; l--) {
    if(!memcmp(&data[l*4+4],a,s)) return true;
    }
  return false;
}
static bool cParseNDS::HasAddr ( const unsigned char *  data,
const unsigned char *  a 
) [static]
static bool cParseNDS::IsSA ( const unsigned char *  data) [static]
static bool cParseNDS::IsSA ( const unsigned char *  data) [static]
static unsigned int cParseNDS::NumAddr ( const unsigned char *  data) [static]
unsigned int cParseNDS::NumAddr ( const unsigned char *  data) [static]

Definition at line 721 of file parse.c.

Referenced by Assemble(), HasAddr(), and PayloadStart().

{
  return ((data[3]&0x30)>>4)+1;
}
static int cParseNDS::PayloadSize ( const unsigned char *  data,
const unsigned char *  a 
) [static]
int cParseNDS::PayloadSize ( const unsigned char *  data,
const unsigned char *  a 
) [static]

Definition at line 773 of file parse.c.

References AddrMode(), PayloadStart(), and SCT_LEN.

Referenced by Assemble().

{
  int l=SCT_LEN(data);
  if(AddrMode(data)==0) return l-(4);
  else {
    const unsigned char *pl=cParseNDS::PayloadStart(data,a); //points to 02 xx yy
    pl+=2+pl[1];
    return *pl;
    }
}
const unsigned char * cParseNDS::PayloadStart ( const unsigned char *  data,
const unsigned char *  a 
) [static]

Definition at line 749 of file parse.c.

References AddrMode(), and NumAddr().

Referenced by Assemble(), PayloadSize(), and cSmartCardVideoGuard2::Update().

{
  if(AddrMode(data)==0) return &data[4];
  else {
    int l;
    for(l=NumAddr(data)-1; l>=0; l--) {
      if(!memcmp(&data[l*4+4],a,AddrMode(data)+1)) break;
      }
    const unsigned char *pl;
    pl=&data[4+NumAddr(data)*4];  // skip address list
    if(*pl!=0x02 && *pl!=0x07) {
      pl+=2;                      // skip 00 00 separator
      pl++;                       // skip the 1st bitmap len
      }
    while(l--) {
      pl+=2+pl[1];                // skip IRD-EMM part, 02 00 or 02 06 xx aabbccdd yy
      pl+=1+*pl;                  // skip sub-EMM payload
      if (*pl == 0x00) pl++;      // skip sub-EMM separator
      pl++;                       // skip the 1st bitmap len
      }
    return pl;
    }
}
static const unsigned char* cParseNDS::PayloadStart ( const unsigned char *  data,
const unsigned char *  a 
) [static]

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