|
SASC-NG
DVBSoftCAM
|
Inheritance diagram for cCCcamCard:Public Member Functions | |
| cCCcamCard (void) | |
| ~cCCcamCard () | |
| void | Setup (int num, const char *Path) |
| bool | Connect (void) |
| void | Disconnect (void) |
| bool | Connected (void) |
| void | WriteCaPmt (void) |
| void | NewCaPmt (int p, const unsigned char *pmt, int len) |
| int | Pid (void) |
| bool | GetCw (unsigned char *Cw, int timeout) |
| void | NewCw (const unsigned char *Cw) |
| cCCcamCard::cCCcamCard | ( | void | ) |
| cCCcamCard::~cCCcamCard | ( | ) |
Definition at line 64 of file cccam.c.
References Disconnect(), and free.
{
Disconnect();
free(capmt);
}
| bool cCCcamCard::Connect | ( | void | ) |
Definition at line 82 of file cccam.c.
References Disconnect(), L_CC_CCCAM, and PRINTF.
Referenced by WriteCaPmt().
{
cMutexLock lock(this);
Disconnect();
ccam_fd=socket(AF_LOCAL,SOCK_STREAM,0);
if(!ccam_fd) {
PRINTF(L_CC_CCCAM,"%d: socket failed: %s",cardnum,strerror(errno));
return false;
}
sockaddr_un serv_addr_un;
memset(&serv_addr_un,0,sizeof(serv_addr_un));
serv_addr_un.sun_family=AF_LOCAL;
snprintf(serv_addr_un.sun_path,sizeof(serv_addr_un.sun_path),path,cardnum);
PRINTF(L_CC_CCCAM,"%d: using camd socket '%s'",cardnum,serv_addr_un.sun_path);
if(connect(ccam_fd,(const sockaddr*)&serv_addr_un,sizeof(serv_addr_un))!=0) {
PRINTF(L_CC_CCCAM,"%d: connect failed: %s",cardnum,strerror(errno));
Disconnect();
return false;
}
PRINTF(L_CC_CCCAM,"%d: opened camd socket",cardnum);
return true;
}
| bool cCCcamCard::Connected | ( | void | ) | [inline] |
Definition at line 50 of file cccam.c.
Referenced by cCardClientCCcam::ProcessECM(), and WriteCaPmt().
{ return ccam_fd>=0; }
| void cCCcamCard::Disconnect | ( | void | ) |
Definition at line 75 of file cccam.c.
Referenced by Connect(), cCardClientCCcam::ProcessECM(), WriteCaPmt(), and ~cCCcamCard().
{
cMutexLock lock(this);
close(ccam_fd);
ccam_fd=-1; newcw=false;
}
| bool cCCcamCard::GetCw | ( | unsigned char * | Cw, |
| int | timeout | ||
| ) |
Definition at line 147 of file cccam.c.
References cTimeMs::Elapsed(), and cCondVar::TimedWait().
Referenced by cCardClientCCcam::ProcessECM().
{
cMutexLock lock(this);
if(newcw && timecw.Elapsed()>3000)
newcw=false; // too old
if(!newcw)
cwwait.TimedWait(*this,timeout);
if(newcw) {
memcpy(Cw,cw,sizeof(cw));
newcw=false;
return true;
}
return false;
}
| void cCCcamCard::NewCaPmt | ( | int | p, |
| const unsigned char * | pmt, | ||
| int | len | ||
| ) |
Definition at line 122 of file cccam.c.
References free, LIST_ONLY, MALLOC, and WriteCaPmt().
Referenced by cCardClientCCcam::ProcessECM().
{
cMutexLock lock(this);
free(capmt); pid=0; newcw=false;
capmt=MALLOC(unsigned char,len);
if(capmt) {
memcpy(capmt,pmt,len);
pmtlen=len;
capmt[6]=LIST_ONLY;
pid=p;
WriteCaPmt();
}
}
| void cCCcamCard::NewCw | ( | const unsigned char * | Cw | ) |
Definition at line 136 of file cccam.c.
References cCondVar::Broadcast(), and cTimeMs::Set().
Referenced by cCardClientCCcam::Action().
| int cCCcamCard::Pid | ( | void | ) | [inline] |
Definition at line 53 of file cccam.c.
Referenced by cCardClientCCcam::ProcessECM().
{ return pid; }
| void cCCcamCard::Setup | ( | int | num, |
| const char * | Path | ||
| ) |
| void cCCcamCard::WriteCaPmt | ( | void | ) |
Definition at line 105 of file cccam.c.
References Connect(), Connected(), Disconnect(), L_CC_CCCAM, and PRINTF.
Referenced by NewCaPmt(), and cCardClientCCcam::ProcessECM().
{
cMutexLock lock(this);
if(capmt) {
for(int retry=2; retry>0; retry--) {
if(!Connected() && !Connect()) break;
int r=write(ccam_fd,capmt,pmtlen);
if(r==pmtlen) {
newcw=false;
break;
}
PRINTF(L_CC_CCCAM,"%d: write failed: %s",cardnum,strerror(errno));
Disconnect();
}
}
}