SASC-NG
DVBSoftCAM

cSmartCard Class Reference

#include <smartcard.h>

Inheritance diagram for cSmartCard:

List of all members.

Public Member Functions

 cSmartCard (const struct CardConfig *Cfg, const struct StatusMsg *Msg)
virtual ~cSmartCard ()
virtual bool Init (void)=0
virtual bool Decode (const cEcmInfo *ecm, const unsigned char *data, unsigned char *cw)=0
virtual bool Update (int pid, int caid, const unsigned char *data)
virtual bool CanHandle (unsigned short CaId)
bool Setup (cSmartCardSlot *Slot, int sermode, const struct Atr *Atr, unsigned char *Sb)
bool CardUp (void)
bool GetCardIdStr (char *str, int len)
bool GetCardInfoStr (char *str, int len)

Protected Member Functions

int SerRead (unsigned char *data, int len, int to=0)
int SerWrite (const unsigned char *data, int len)
bool IsoRead (const unsigned char *cmd, unsigned char *data)
bool IsoWrite (const unsigned char *cmd, const unsigned char *data)
bool Status (void)
void NewCardConfig (const struct CardConfig *Cfg)
int CheckSctLen (const unsigned char *data, int off)
void CaidsChanged (void)

Protected Attributes

struct Atr * atr
unsigned char * sb
char idStr [IDSTR_LEN]
cInfoStr infoStr

Detailed Description

Definition at line 110 of file smartcard.h.


Constructor & Destructor Documentation

cSmartCard::cSmartCard ( const struct CardConfig *  Cfg,
const struct StatusMsg *  Msg 
)

Definition at line 1917 of file smartcard.c.

References idStr, NewCardConfig(), and sb.

{
  msg=Msg;
  slot=0; sb=0; atr=0; idStr[0]=0; cardUp=false;
  NewCardConfig(Cfg);
}
virtual cSmartCard::~cSmartCard ( ) [inline, virtual]

Definition at line 133 of file smartcard.h.

{};

Member Function Documentation

void cSmartCard::CaidsChanged ( void  ) [protected]
virtual bool cSmartCard::CanHandle ( unsigned short  CaId) [inline, virtual]
bool cSmartCard::CardUp ( void  ) [inline]

Definition at line 140 of file smartcard.h.

Referenced by cSmartCardSlot::LockCard().

{ return cardUp; }
int cSmartCard::CheckSctLen ( const unsigned char *  data,
int  off 
) [protected]

Definition at line 1992 of file smartcard.c.

References L_CORE_SC, MAX_LEN, PRINTF, and SCT_LEN.

Referenced by cSmartCardCryptoworks::Decode(), cSmartCardConax::Decode(), cSmartCardCryptoworks::Update(), and cSmartCardConax::Update().

{
  int l=SCT_LEN(data);
  if(l+off > MAX_LEN) {
    PRINTF(L_CORE_SC,"section too long %d > %d",l,MAX_LEN-off);
    l=-1;
    }
  return l;
}
virtual bool cSmartCard::Decode ( const cEcmInfo *  ecm,
const unsigned char *  data,
unsigned char *  cw 
) [pure virtual]
bool cSmartCard::GetCardIdStr ( char *  str,
int  len 
)

Definition at line 1930 of file smartcard.c.

References idStr, and strn0cpy().

Referenced by cSmartCardSlot::GetCardIdStr().

{
  strn0cpy(str,idStr,len);
  return (str[0]!=0);
}
bool cSmartCard::GetCardInfoStr ( char *  str,
int  len 
)

Definition at line 1936 of file smartcard.c.

References cInfoStr::Get(), and infoStr.

Referenced by cSmartCardSlot::GetCardInfoStr().

{
  return infoStr.Get(str,len);
}
virtual bool cSmartCard::Init ( void  ) [pure virtual]
bool cSmartCard::IsoRead ( const unsigned char *  cmd,
unsigned char *  data 
) [protected]
bool cSmartCard::IsoWrite ( const unsigned char *  cmd,
const unsigned char *  data 
) [protected]
void cSmartCard::NewCardConfig ( const struct CardConfig *  Cfg) [protected]

Definition at line 1924 of file smartcard.c.

References cSmartCardSlot::SetCardConfig().

Referenced by cSmartCard(), and cSmartCardVideoGuard2::Init().

{
  cfg=Cfg;
  if(slot) slot->SetCardConfig(cfg);
}
int cSmartCard::SerRead ( unsigned char *  data,
int  len,
int  to = 0 
) [protected]

Definition at line 1950 of file smartcard.c.

References L_CORE_SC, PRINTF, and cSmartCardSlot::RawRead().

{
  if(atr->T==1 || atr->T==14) return slot->RawRead(data,len,to);
  PRINTF(L_CORE_SC,"%d: SerRead() not allowed for ISO compliant cards (T=%d)",slotnum,atr->T);
  return -1;
}
int cSmartCard::SerWrite ( const unsigned char *  data,
int  len 
) [protected]

Definition at line 1957 of file smartcard.c.

References L_CORE_SC, PRINTF, and cSmartCardSlot::RawWrite().

{
  if(atr->T==1 || atr->T==14) return slot->RawWrite(data,len);
  PRINTF(L_CORE_SC,"%d: SerWrite() not allowed for ISO compliant cards (T=%d)",slotnum,atr->T);
  return -1;
}
bool cSmartCard::Setup ( cSmartCardSlot *  Slot,
int  sermode,
const struct Atr *  Atr,
unsigned char *  Sb 
)

Definition at line 1941 of file smartcard.c.

References Init(), sb, cSmartCardSlot::SetCardConfig(), and cSmartCardSlot::SlotNum().

Referenced by cSmartCardSlot::Action().

{
  slot=Slot; atr=Atr; sb=Sb;
  slotnum=slot->SlotNum(); slot->SetCardConfig(cfg);
  cardUp=false;
  if(cfg->SerMode==sermode && Init()) cardUp=true;
  return cardUp;
}
virtual bool cSmartCard::Update ( int  pid,
int  caid,
const unsigned char *  data 
) [inline, virtual]

Member Data Documentation

unsigned char* cSmartCard::sb [protected]

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