ci-alc automatically Multi-Decrypt

This commit is contained in:
max10
2016-08-05 23:21:48 +02:00
parent b60543ad6b
commit 7f178d38f9
7 changed files with 209 additions and 101 deletions

View File

@@ -185,6 +185,8 @@ eData waitData(int fd, unsigned char* buffer, int* len)
static bool transmitData(tSlot* slot, unsigned char* d, int len) static bool transmitData(tSlot* slot, unsigned char* d, int len)
{ {
printf("%s -> %s len(%d)\n", FILENAME, __func__, len);
#ifdef direct_write #ifdef direct_write
int res = write(slot->fd, d, len); int res = write(slot->fd, d, len);
@@ -196,7 +198,6 @@ static bool transmitData(tSlot* slot, unsigned char* d, int len)
} }
#else #else
#if y_debug #if y_debug
printf("SendData with data (len %d) >\n", len);
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
printf("%02x ", d[i]); printf("%02x ", d[i]);
printf("\n"); printf("\n");
@@ -428,7 +429,7 @@ bool cCA::SendMessage(const CA_MESSAGE *msg)
void cCA::MenuEnter(enum CA_SLOT_TYPE, uint32_t bSlotIndex) void cCA::MenuEnter(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
{ {
printf("%s %s bSlotIndex: %d\n", FILENAME, __FUNCTION__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
@@ -456,7 +457,7 @@ void cCA::MenuEnter(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
void cCA::MenuAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint32_t choice) void cCA::MenuAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint32_t choice)
{ {
printf("%s %s bSlotIndex: %d choice: %c\n", FILENAME, __FUNCTION__, bSlotIndex, choice); printf("%s -> %s Slot(%d) choice(%d)\n", FILENAME, __func__, bSlotIndex, choice);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
@@ -472,7 +473,7 @@ void cCA::MenuAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint32_t choice)
void cCA::InputAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint8_t * pBuffer, int nLength) void cCA::InputAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint8_t * pBuffer, int nLength)
{ {
printf("%s %s bSlotIndex: %d\n", FILENAME, __FUNCTION__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
@@ -489,7 +490,8 @@ void cCA::InputAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint8_t * pBuffer,
void cCA::MenuClose(enum CA_SLOT_TYPE, uint32_t bSlotIndex) void cCA::MenuClose(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
{ {
printf("%s %s bSlotIndex: %d\n", FILENAME, __FUNCTION__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
@@ -505,13 +507,13 @@ void cCA::MenuClose(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
uint32_t cCA::GetNumberCISlots(void) uint32_t cCA::GetNumberCISlots(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
return num_slots; return num_slots;
} }
uint32_t cCA::GetNumberSmartCardSlots(void) uint32_t cCA::GetNumberSmartCardSlots(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
return 0; return 0;
} }
@@ -545,6 +547,8 @@ bool cCA::ModulePresent(enum CA_SLOT_TYPE, uint32_t slot)
void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot) void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
{ {
printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
bool haveFound = false; bool haveFound = false;
@@ -585,9 +589,15 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
(*it)->cam_caids.clear(); (*it)->cam_caids.clear();
(*it)->newCapmt = false; (*it)->newCapmt = false;
(*it)->recordUse = false; (*it)->multi = false;
(*it)->liveUse = false; for (int j = 0; j < CI_MAX_MULTI; j++)
(*it)->tpid = 0; {
(*it)->SID[j] = 0;
(*it)->recordUse[j] = false;
(*it)->liveUse[j] = false;
}
(*it)->TP = 0;
(*it)->ci_use_count = 0;
(*it)->pmtlen = 0; (*it)->pmtlen = 0;
(*it)->source = TUNER_A; (*it)->source = TUNER_A;
(*it)->camask = 0; (*it)->camask = 0;
@@ -620,37 +630,43 @@ int cCA::GetCAIDS(CaIdVector &Caids)
return 0; return 0;
} }
bool cCA::StopLiveCI( u64 tpid, u8 source, u32 calen) bool cCA::StopLiveCI( u64 TP, u16 SID, u8 source, u32 calen)
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
if ((*it)->liveUse && (*it)->tpid == tpid && (*it)->source == source && !calen) for (int j = 0; j < CI_MAX_MULTI; j++)
{ {
(*it)->liveUse = false; if ((*it)->liveUse[j] && (*it)->TP == TP && (*it)->SID[j] == SID && (*it)->source == source && !calen)
return true; {
(*it)->liveUse[j] = false;
return true;
}
} }
} }
return false; return false;
} }
bool cCA::StopRecordCI( u64 tpid, u8 source, u32 calen) bool cCA::StopRecordCI( u64 TP, u16 SID, u8 source, u32 calen)
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
if ((*it)->recordUse && (*it)->tpid == tpid && (*it)->source == source && !calen) for (int j = 0; j < CI_MAX_MULTI; j++)
{ {
(*it)->recordUse = false; if ((*it)->recordUse[j] && (*it)->TP == TP && (*it)->SID[j] == SID && (*it)->source == source && !calen)
return true; {
(*it)->recordUse[j] = false;
return true;
}
} }
} }
return false; return false;
} }
SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled) SlotIt cCA::FindFreeSlot(u64 TP, u8 source, u16 SID, ca_map_t camap, unsigned char scrambled)
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
@@ -661,8 +677,14 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned
{ {
if (!scrambled) { continue; } if (!scrambled) { continue; }
if ((*it)->tpid == tpid && (*it)->source == source) for (int j = 0; j < CI_MAX_MULTI; j++)
return it; {
if ((*it)->TP == TP && (*it)->SID[j] == SID && (*it)->source == source)
return it;
}
if ((*it)->multi && (*it)->TP == TP && (*it)->source == source && (*it)->ci_use_count < CI_MAX_MULTI)
return it;
} }
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
@@ -672,13 +694,13 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned
if ((*it)->bsids.size()) if ((*it)->bsids.size())
{ {
for (i = 0; i < (*it)->bsids.size(); i++) for (i = 0; i < (*it)->bsids.size(); i++)
if ((*it)->bsids[i] == sid) {goto OUT;} if ((*it)->bsids[i] == SID) {goto OUT;}
if (i == (*it)->bsids.size()) {(*it)->SidBlackListed = false;} if (i == (*it)->bsids.size()) {(*it)->SidBlackListed = false;}
} }
if ((*it)->camIsReady && (*it)->hasCAManager && (*it)->hasAppManager && !(*it)->recordUse) if ((*it)->camIsReady && (*it)->hasCAManager && (*it)->hasAppManager && !(*it)->recordUse[0])
{ {
if (!checkLiveSlot || (!(*it)->liveUse || ((*it)->liveUse && (*it)->tpid == tpid))) if (!checkLiveSlot || (!(*it)->liveUse[0] || ((*it)->liveUse[0] && (*it)->TP == TP && (*it)->SID[0] == SID)))
{ {
#if x_debug #if x_debug
printf("Slot Caids: %d > ", (*it)->cam_caids.size()); printf("Slot Caids: %d > ", (*it)->cam_caids.size());
@@ -710,16 +732,19 @@ OUT:
} }
/* erstmal den capmt wie er von Neutrino kommt in den Slot puffern */ /* erstmal den capmt wie er von Neutrino kommt in den Slot puffern */
bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char * cabuf, u32 calen, const unsigned char * /*rawpmt*/, u32 /*rawlen*/, enum CA_SLOT_TYPE /*SlotType*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled) bool cCA::SendCAPMT(u64 tpid, u8 source, u8 camask, const unsigned char * cabuf, u32 calen, const unsigned char * /*rawpmt*/, u32 /*rawlen*/, enum CA_SLOT_TYPE /*SlotType*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled)
{ {
u16 SID = (u16)(tpid & 0xFFFF); u16 SID = (u16)(tpid & 0xFFFF);
u64 TP = tpid >> 16;
unsigned int i = 0; unsigned int i = 0;
bool sid_found = false;
//bool recordUse_found = false;
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
if (!num_slots) return true; /* stb's without ci-slots */ if (!num_slots) return true; /* stb's without ci-slots */
#if x_debug #if x_debug
printf("TPID: %llX\n", tpid); printf("TP: %llX\n", TP);
printf("SID: %04X\n", SID); printf("SID: %04X\n", SID);
printf("SOURCE_DEMUX: %X\n", source_demux); printf("SOURCE: %X\n", source);
printf("CA_MASK: %X\n", camask); printf("CA_MASK: %X\n", camask);
printf("CALEN: %d\n", calen); printf("CALEN: %d\n", calen);
printf("Scrambled: %d\n", scrambled); printf("Scrambled: %d\n", scrambled);
@@ -730,63 +755,104 @@ bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char *
{ {
if (mode) if (mode)
{ {
if (StopRecordCI(tpid, source_demux, calen)) if (StopRecordCI(TP, SID, source, calen))
printf("Record CI set free\n"); printf("Record CI set free\n");
} }
else else
{ {
if (StopLiveCI(tpid, source_demux, calen)) if (StopLiveCI(TP, SID, source, calen))
printf("Live CI set free\n"); printf("Live CI set free\n");
} }
} }
if (calen == 0) if (calen == 0)
return true; return true;
SlotIt It = FindFreeSlot(tpid, source_demux, SID, cm, scrambled); SlotIt It = FindFreeSlot(TP, source, SID, cm, scrambled);
if ((*It)) if ((*It))
{ {
printf("Slot: %d\n", (*It)->slot); printf("Slot: %d\n", (*It)->slot);
/* outcommented, it seems to be not necessary */
if (enabled) #if 0
{
if (mode)
{
if(!checkLiveSlot)
(*It)->liveUse = false;
(*It)->recordUse = true;
}
else if (!(*It)->recordUse)
(*It)->liveUse = true;
}
SlotIt It2 = GetSlot(!(*It)->slot); SlotIt It2 = GetSlot(!(*It)->slot);
if ((*It2) && ((*It)->hasCCManager || (*It2)->hasCCManager)) if ((*It2) && ((*It)->hasCCManager || (*It2)->hasCCManager))
{ {
if (source_demux == (*It2)->source) if (source == (*It2)->source)
{ {
if ((*It2)->recordUse) for (int j = 0; j < CI_MAX_MULTI; j++)
{
if ((*It2)->recordUse[j])
recordUse_found = true;
}
if (recordUse_found)
(*It)->SidBlackListed = true; (*It)->SidBlackListed = true;
else else
{ {
SendNullPMT((tSlot*)(*It2)); SendNullPMT((tSlot*)(*It2));
(*It2)->tpid = 0;
(*It2)->scrambled = 0; (*It2)->scrambled = 0;
(*It2)->TP = 0;
for (int j = 0; j < CI_MAX_MULTI; j++)
(*It2)->SID[j] = 0;
} }
} }
} }
#endif
if ((*It)->tpid != tpid || (*It)->source != source_demux) for (int j = 0; j < CI_MAX_MULTI; j++)
{ {
(*It)->tpid = tpid; if ((*It)->SID[j] == SID)
(*It)->source = source_demux; sid_found = true;
}
if ((*It)->multi && (*It)->TP == TP && (*It)->source == source && !sid_found && (*It)->ci_use_count < CI_MAX_MULTI)
{
int pos = 3;
(*It)->SID[(*It)->ci_use_count] = SID;
(*It)->ci_use_count++;
if (!(cabuf[pos] & 0x80))
pos +=1;
else
pos += ((cabuf[pos] & 0x7F) + 1);
(*It)->pmtlen = calen;
for (i = 0; i < calen; i++)
(*It)->pmtdata[i] = cabuf[i];
(*It)->pmtdata[pos] = 0x04; // CAPMT_ADD
(*It)->newCapmt = true;
}
else if ((*It)->TP != TP || !sid_found || (*It)->source != source)
{
for (int j = 0; j < CI_MAX_MULTI; j++)
(*It)->SID[j] = 0;
(*It)->SID[0] = SID;
(*It)->ci_use_count = 1;
(*It)->TP = TP;
(*It)->source = source;
(*It)->pmtlen = calen; (*It)->pmtlen = calen;
for (i = 0; i < calen; i++) for (i = 0; i < calen; i++)
(*It)->pmtdata[i] = cabuf[i]; (*It)->pmtdata[i] = cabuf[i];
(*It)->newCapmt = true; (*It)->newCapmt = true;
} else if ((*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed) } else if ((*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed)
(*It)->ccmgrSession->resendKey((tSlot*)(*It)); (*It)->ccmgrSession->resendKey((tSlot*)(*It));
for (int j = 0; j < CI_MAX_MULTI; j++)
{
if (enabled && (*It)->SID[j] == SID)
{
if (mode)
{
if(!checkLiveSlot)
(*It)->liveUse[j] = false;
(*It)->recordUse[j] = true;
}
else if (!(*It)->recordUse[j])
(*It)->liveUse[j] = true;
}
}
} }
else else
{ {
@@ -812,7 +878,7 @@ bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char *
cCA::cCA(int Slots) cCA::cCA(int Slots)
{ {
printf("%s %s %d\n", FILENAME, __FUNCTION__, Slots); printf("%s -> %s %d\n", FILENAME, __func__, Slots);
int fd, i; int fd, i;
char filename[128]; char filename[128];
@@ -845,9 +911,15 @@ cCA::cCA(int Slots)
slot->mmiOpened = false; slot->mmiOpened = false;
slot->newCapmt = false; slot->newCapmt = false;
slot->recordUse = false; slot->multi = false;
slot->liveUse = false; for (int j = 0; j < CI_MAX_MULTI; j++)
slot->tpid = 0; {
slot->SID[j] = 0;
slot->recordUse[j] = false;
slot->liveUse[j] = false;
}
slot->TP = 0;
slot->ci_use_count = 0;
slot->pmtlen = 0; slot->pmtlen = 0;
slot->source = TUNER_A; slot->source = TUNER_A;
slot->camask = 0; slot->camask = 0;
@@ -880,7 +952,7 @@ cCA::cCA(int Slots)
cCA::~cCA() cCA::~cCA()
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
} }
static cCA* pcCAInstance = NULL; static cCA* pcCAInstance = NULL;
@@ -899,7 +971,7 @@ cCA * cCA::GetInstance()
cCA::cCA(void) cCA::cCA(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
} }
void cCA::setSource(tSlot* slot) void cCA::setSource(tSlot* slot)
@@ -1160,9 +1232,15 @@ void cCA::slot_pollthread(void *c)
slot->cam_caids.clear(); slot->cam_caids.clear();
slot->newCapmt = false; slot->newCapmt = false;
slot->recordUse = false; slot->multi = false;
slot->liveUse = false; for (int j = 0; j < CI_MAX_MULTI; j++)
slot->tpid = 0; {
slot->SID[j] = 0;
slot->recordUse[j] = false;
slot->liveUse[j] = false;
}
slot->TP = 0;
slot->ci_use_count = 0;
slot->pmtlen = 0; slot->pmtlen = 0;
slot->source = TUNER_A; slot->source = TUNER_A;
slot->camask = 0; slot->camask = 0;
@@ -1237,13 +1315,13 @@ cCA *CA = cCA::GetInstance();
bool cCA::SendCaPMT(tSlot* slot) bool cCA::SendCaPMT(tSlot* slot)
{ {
printf("%s:%s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
if ((slot->fd > 0) && (slot->camIsReady)) if ((slot->fd > 0) && (slot->camIsReady))
{ {
if (slot->hasCAManager) if (slot->hasCAManager)
{ {
#if x_debug printf("buffered capmt(%d): > \n", slot->pmtlen);
printf("buffered capmt(0x%X): > \n", slot->pmtlen); #if y_debug
for (unsigned int i = 0; i < slot->pmtlen; i++) for (unsigned int i = 0; i < slot->pmtlen; i++)
printf("%02X ", slot->pmtdata[i]); printf("%02X ", slot->pmtdata[i]);
printf("\n"); printf("\n");
@@ -1263,42 +1341,42 @@ bool cCA::SendCaPMT(tSlot* slot)
bool cCA::Init(void) bool cCA::Init(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
return true; return true;
} }
bool cCA::SendDateTime(void) bool cCA::SendDateTime(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
return false; return false;
} }
bool cCA::Start(void) bool cCA::Start(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
return true; return true;
} }
void cCA::Stop(void) void cCA::Stop(void)
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __func__);
} }
void cCA::Ready(bool p) void cCA::Ready(bool p)
{ {
printf("%s %s param:%d\n", FILENAME, __FUNCTION__, (int)p); printf("%s -> %s param:%d\n", FILENAME, __func__, (int)p);
} }
void cCA::SetInitMask(enum CA_INIT_MASK p) void cCA::SetInitMask(enum CA_INIT_MASK p)
{ {
printf("%s %s param:%d\n", FILENAME, __FUNCTION__, (int)p); printf("%s -> %s param:%d\n", FILENAME, __func__, (int)p);
} }
SlotIt cCA::GetSlot(unsigned int slot) SlotIt cCA::GetSlot(unsigned int slot)
{ {
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
if ((*it)->slot == slot && (*it)->ccmgr_ready && (*it)->hasCCManager && (*it)->scrambled) if ((*it)->slot == slot && (*it)->ccmgr_ready && (*it)->hasCCManager)
return it; return it;
return it; return it;
} }
@@ -1327,10 +1405,15 @@ bool cCA::CheckCerts(void)
bool cCA::checkChannelID(u64 chanID) bool cCA::checkChannelID(u64 chanID)
{ {
std::list<tSlot*>::iterator it; std::list<tSlot*>::iterator it;
u16 SID = (u16)(chanID & 0xFFFF);
u64 TP = chanID >> 16;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
if ((*it)->tpid == chanID && !(*it)->SidBlackListed) for (int j = 0; j < CI_MAX_MULTI; j++)
return true; {
if ((*it)->TP == TP && (*it)->SID[j] == SID && !(*it)->SidBlackListed)
return true;
}
} }
return false; return false;
} }

View File

@@ -26,6 +26,9 @@
#define T_DATA_LAST 0xA0 // convey data from higher constructed h<->m #define T_DATA_LAST 0xA0 // convey data from higher constructed h<->m
#define T_DATA_MORE 0xA1 // convey data from higher constructed h<->m #define T_DATA_MORE 0xA1 // convey data from higher constructed h<->m
/* max multi decrypt per ci-cam */
#define CI_MAX_MULTI 4
enum CA_INIT_MASK { enum CA_INIT_MASK {
CA_INIT_SC = 1, CA_INIT_SC = 1,
CA_INIT_CI, CA_INIT_CI,
@@ -194,9 +197,12 @@ typedef struct
char name[512]; char name[512];
bool newCapmt; bool newCapmt;
bool recordUse; bool multi;
bool liveUse; bool recordUse[CI_MAX_MULTI];
u64 tpid; bool liveUse[CI_MAX_MULTI];
u16 SID[CI_MAX_MULTI];
u64 TP;
int ci_use_count;
u32 pmtlen; u32 pmtlen;
u8 source; u8 source;
u8 camask; u8 camask;
@@ -285,8 +291,8 @@ public:
bool SendCAPMT(u64 /*Source*/, u8 /*DemuxSource*/, u8 /*DemuxMask*/, const unsigned char * /*CAPMT*/, u32 /*CAPMTLen*/, const unsigned char * /*RawPMT*/, u32 /*RawPMTLen*/, enum CA_SLOT_TYPE SlotType = CA_SLOT_TYPE_ALL, bool SendCAPMT(u64 /*Source*/, u8 /*DemuxSource*/, u8 /*DemuxMask*/, const unsigned char * /*CAPMT*/, u32 /*CAPMTLen*/, const unsigned char * /*RawPMT*/, u32 /*RawPMTLen*/, enum CA_SLOT_TYPE SlotType = CA_SLOT_TYPE_ALL,
unsigned char scrambled = 0, ca_map_t camap = std::set<int>(), int mode = 0, bool enabled = false); unsigned char scrambled = 0, ca_map_t camap = std::set<int>(), int mode = 0, bool enabled = false);
bool StopRecordCI( u64 tpid, u8 source, u32 calen); bool StopRecordCI( u64 TP, u16 SID, u8 source, u32 calen);
bool StopLiveCI( u64 tpid, u8 source, u32 calen); bool StopLiveCI( u64 TP, u16 SID, u8 source, u32 calen);
SlotIt FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled); SlotIt FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned char scrambled);
SlotIt GetSlot(unsigned int slot); SlotIt GetSlot(unsigned int slot);
bool SendDateTime(void); bool SendDateTime(void);

View File

@@ -43,7 +43,7 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons
printf(" application_type: %d\n", ((unsigned char*)data)[0]); printf(" application_type: %d\n", ((unsigned char*)data)[0]);
printf(" application_manufacturer: %02x %02x\n", ((unsigned char*)data)[2], ((unsigned char*)data)[1]); printf(" application_manufacturer: %02x %02x\n", ((unsigned char*)data)[2], ((unsigned char*)data)[1]);
printf(" manufacturer_code: %02x %02x\n", ((unsigned char*)data)[4], ((unsigned char*)data)[3]); printf(" manufacturer_code: %02x %02x\n", ((unsigned char*)data)[4], ((unsigned char*)data)[3]);
printf(" menu string: \n"); printf(" menu string: ");
dl = ((unsigned char*)data)[5]; dl = ((unsigned char*)data)[5];
if ((dl + 6) > len) if ((dl + 6) > len)
{ {
@@ -58,7 +58,9 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons
printf("\n"); printf("\n");
strcpy(slot->name, str); strcpy(slot->name, str);
printf("%s set cam name %s on slot %d, %p\n", FILENAME, slot->name, slot->slot, slot); if (!strcmp(slot->name, "AlphaCrypt"))
slot->multi = true;
printf("%s set cam name %s on slot(%d)\n", FILENAME, slot->name, slot->slot);
break; break;
} }
default: default:
@@ -82,7 +84,7 @@ int eDVBCIApplicationManagerSession::doAction()
return 1; return 1;
} }
case stateFinal: case stateFinal:
printf("in final state."); printf("%s -> in final state\n", FILENAME);
wantmenu = 0; wantmenu = 0;
if (wantmenu) if (wantmenu)
{ {

View File

@@ -1147,7 +1147,11 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_data_req(tSlot *tslot, cons
return true; return true;
} }
void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_sync_req(tSlot *tslot, const uint8_t *data, unsigned int len) void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_sync_req(tSlot *tslot, const uint8_t *data, unsigned int
#if y_debug
len
#endif
)
{ {
const uint8_t sync_cnf_tag[3] = { 0x9f, 0x90, 0x10 }; const uint8_t sync_cnf_tag[3] = { 0x9f, 0x90, 0x10 };
uint8_t dest[64]; uint8_t dest[64];
@@ -1337,7 +1341,11 @@ int eDVBCIContentControlManagerSession::doAction()
void eDVBCIContentControlManagerSession::resendKey(tSlot *tslot) void eDVBCIContentControlManagerSession::resendKey(tSlot *tslot)
{ {
if (!tslot->SidBlackListed && (tslot->recordUse || tslot->liveUse)) /* Fix me ! no ci* cam with multi decrypt is known
* therefore for now it is OK to use element [0]
* in bool arrays */
if (!tslot->SidBlackListed && (tslot->recordUse[0] || tslot->liveUse[0]))
descrambler_set_key((int)tslot->source, tslot->lastParity, tslot->lastKey); descrambler_set_key((int)tslot->source, tslot->lastParity, tslot->lastKey);
} }

View File

@@ -135,11 +135,11 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i
if ((d + 3) > max) if ((d + 3) > max)
break; break;
printf("text tag: %02x %02x %02x\n", d[0], d[1], d[2]); //printf("text tag: %02x %02x %02x\n", d[0], d[1], d[2]);
d += 3; d += 3;
d += eDVBCISession::parseLengthField(d, textlen); d += eDVBCISession::parseLengthField(d, textlen);
printf("%d bytes text", textlen); printf("%d bytes text > ", textlen);
if ((d + textlen) > max) if ((d + textlen) > max)
break; break;
@@ -159,7 +159,8 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i
{ {
strcpy(listInfo->choice_item[listInfo->choice_nb], str); strcpy(listInfo->choice_item[listInfo->choice_nb], str);
listInfo->choice_nb++; listInfo->choice_nb++;
printf("%d. %s\n", listInfo->choice_nb, listInfo->choice_item[listInfo->choice_nb - 1]); printf("%d. ", listInfo->choice_nb);
//printf("%s\n", listInfo->choice_item[listInfo->choice_nb - 1]);
} }
while (textlen--) while (textlen--)
printf("%c", *d++); printf("%c", *d++);
@@ -234,6 +235,8 @@ int eDVBCIMMISession::doAction()
int eDVBCIMMISession::stopMMI() int eDVBCIMMISession::stopMMI()
{ {
printf("%s -> %s\n", FILENAME, __func__);
unsigned char tag[] = {0x9f, 0x88, 0x00}; unsigned char tag[] = {0x9f, 0x88, 0x00};
unsigned char data[] = {0x00}; unsigned char data[] = {0x00};
sendAPDU(tag, data, 1); sendAPDU(tag, data, 1);
@@ -244,7 +247,7 @@ int eDVBCIMMISession::stopMMI()
int eDVBCIMMISession::answerText(int answer) int eDVBCIMMISession::answerText(int answer)
{ {
printf("eDVBCIMMISession::answerText(%d)\n", answer); printf("%s -> %s(%d)\n", FILENAME, __func__, answer);
unsigned char tag[] = {0x9f, 0x88, 0x0B}; unsigned char tag[] = {0x9f, 0x88, 0x0B};
unsigned char data[] = {0x00}; unsigned char data[] = {0x00};
@@ -256,7 +259,7 @@ int eDVBCIMMISession::answerText(int answer)
int eDVBCIMMISession::answerEnq(char * answer, int len) int eDVBCIMMISession::answerEnq(char * answer, int len)
{ {
printf("eDVBCIMMISession::answerEnq(%d bytes)\n", len); printf("%s -> %s(%d bytes)\n", FILENAME, __func__, len);
unsigned char data[len + 1]; unsigned char data[len + 1];
data[0] = 0x01; // answer ok data[0] = 0x01; // answer ok
@@ -270,7 +273,7 @@ int eDVBCIMMISession::answerEnq(char * answer, int len)
int eDVBCIMMISession::cancelEnq() int eDVBCIMMISession::cancelEnq()
{ {
printf("eDVBCIMMISession::cancelEnq()\n"); printf("%s -> %s\n", FILENAME, __func__);
unsigned char tag[] = {0x9f, 0x88, 0x08}; unsigned char tag[] = {0x9f, 0x88, 0x08};
unsigned char data[] = {0x00}; // canceled unsigned char data[] = {0x00}; // canceled

View File

@@ -7,22 +7,25 @@ static const char * FILENAME = "[dvbci_resmgr]";
int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)RES %02x %02x %02x (len = %d): \n", session_nb, tag[0], tag[1], tag[2], len); printf("SESSION(%d)RES %02x %02x %02x (len = %d): \n", session_nb, tag[0], tag[1], tag[2], len);
for (int i = 0; i < len; i++) if (len)
printf("%02x ", ((const unsigned char*)data)[i]); {
printf("\n"); for (int i = 0; i < len; i++)
printf("%02x ", ((const unsigned char*)data)[i]);
printf("\n");
}
if ((tag[0] == 0x9f) && (tag[1] == 0x80)) if ((tag[0] == 0x9f) && (tag[1] == 0x80))
{ {
switch (tag[2]) switch (tag[2])
{ {
case 0x10: // profile enquiry case 0x10: // profile enquiry
printf("cam fragt was ich kann.\n"); printf("%s -> cam asks what I'm able to\n", FILENAME);
state = stateProfileEnquiry; state = stateProfileEnquiry;
return 1; return 1;
break; break;
case 0x11: // Tprofile case 0x11: // Tprofile
printf("mein cam kann: "); printf("%s -> my cam can do: ", FILENAME);
if (!len) if (!len)
printf("nichts\n"); printf("nothing");
else else
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
printf("%02x ", ((const unsigned char*)data)[i]); printf("%02x ", ((const unsigned char*)data)[i]);

View File

@@ -107,7 +107,7 @@ void eDVBCISession::recvCreateSessionResponse(const unsigned char *data)
status = data[0]; status = data[0];
state = stateStarted; state = stateStarted;
action = 1; action = 1;
printf("create Session Response, status %x\n", status); printf("%s -> %s status(%x)\n", FILENAME, __func__, status);
} }
void eDVBCISession::recvCloseSessionRequest(const unsigned char *data) void eDVBCISession::recvCloseSessionRequest(const unsigned char *data)
@@ -115,11 +115,13 @@ void eDVBCISession::recvCloseSessionRequest(const unsigned char *data)
status = data[0]; status = data[0];
state = stateInDeletion; state = stateInDeletion;
action = 1; action = 1;
printf("close Session Request\n"); printf("%s -> %s\n", FILENAME, __func__);
} }
void eDVBCISession::deleteSessions(const tSlot *slot) void eDVBCISession::deleteSessions(const tSlot *slot)
{ {
printf("%s -> %s\n", FILENAME, __func__);
for (unsigned short session_nb = 0; session_nb < SLMS; ++session_nb) for (unsigned short session_nb = 0; session_nb < SLMS; ++session_nb)
{ {
if (sessions[session_nb] && sessions[session_nb]->slot == slot) if (sessions[session_nb] && sessions[session_nb]->slot == slot)
@@ -132,11 +134,13 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
unsigned long tag; unsigned long tag;
unsigned short session_nb; unsigned short session_nb;
printf("%s -> %s\n", FILENAME, __func__);
for (session_nb = 1; session_nb < SLMS; ++session_nb) for (session_nb = 1; session_nb < SLMS; ++session_nb)
if (!sessions[session_nb - 1]) if (!sessions[session_nb - 1])
break; break;
printf("use session_nb = %d\n", session_nb); printf("%s -> use session_nb = %d\n", FILENAME, session_nb);
if (session_nb == SLMS) if (session_nb == SLMS)
{ {
status = 0xF3; status = 0xF3;
@@ -148,7 +152,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
tag |= resource_identifier[2] << 8; tag |= resource_identifier[2] << 8;
tag |= resource_identifier[3]; tag |= resource_identifier[3];
printf("Tag: %08lx\n", tag); printf("Tag: %08lx > ", tag);
switch (tag) switch (tag)
{ {
@@ -170,14 +174,14 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
printf("DATE-TIME\n"); printf("DATE-TIME\n");
break; break;
case 0x00400041: case 0x00400041:
printf("MMI\n");
sessions[session_nb - 1] = new eDVBCIMMISession(slot); sessions[session_nb - 1] = new eDVBCIMMISession(slot);
printf("MMI - create session\n");
break; break;
if (cCA::GetInstance()->CheckCerts()) if (cCA::GetInstance()->CheckCerts())
{ {
case 0x008c1001: case 0x008c1001:
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
printf("CC MANAGER\n"); printf("CC MANAGER\n");
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
break; break;
} }
case 0x00100041: case 0x00100041:
@@ -197,7 +201,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
return NULL; return NULL;
} }
printf("new session nb %d %p\n", session_nb, sessions[session_nb - 1]); printf("%s -> new session nb %d %p\n", FILENAME, session_nb, sessions[session_nb - 1]);
sessions[session_nb - 1]->session_nb = session_nb; sessions[session_nb - 1]->session_nb = session_nb;
if (sessions[session_nb - 1]) if (sessions[session_nb - 1])
@@ -235,7 +239,6 @@ int eDVBCISession::pollAll()
if (r) if (r)
{ {
printf("%s <\n", __func__);
return 1; return 1;
} }
} }