From 7d94090b425c70e96f00bf30900feda84117e47a Mon Sep 17 00:00:00 2001 From: max_10 Date: Fri, 5 Aug 2016 23:21:48 +0200 Subject: [PATCH] ci-alc automatically Multi-Decrypt Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/7f178d38f9e431c2fedf0f07717aa0a111a8e2d0 Author: max_10 Date: 2016-08-05 (Fri, 05 Aug 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- common/ca_ci.cpp | 225 +++++++++++++++++++++++++------------ common/ca_ci.h | 16 ++- libdvbci/dvbci_appmgr.cpp | 8 +- libdvbci/dvbci_ccmgr.cpp | 12 +- libdvbci/dvbci_mmi.cpp | 15 ++- libdvbci/dvbci_resmgr.cpp | 15 ++- libdvbci/dvbci_session.cpp | 19 ++-- 7 files changed, 209 insertions(+), 101 deletions(-) diff --git a/common/ca_ci.cpp b/common/ca_ci.cpp index 16a083e..f66ddd6 100644 --- a/common/ca_ci.cpp +++ b/common/ca_ci.cpp @@ -185,6 +185,8 @@ eData waitData(int fd, unsigned char* buffer, int* len) static bool transmitData(tSlot* slot, unsigned char* d, int len) { + printf("%s -> %s len(%d)\n", FILENAME, __func__, len); + #ifdef direct_write int res = write(slot->fd, d, len); @@ -196,7 +198,6 @@ static bool transmitData(tSlot* slot, unsigned char* d, int len) } #else #if y_debug - printf("SendData with data (len %d) >\n", len); for (int i = 0; i < len; i++) printf("%02x ", d[i]); printf("\n"); @@ -428,7 +429,7 @@ bool cCA::SendMessage(const CA_MESSAGE *msg) 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::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) { - 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::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) { - printf("%s %s bSlotIndex: %d\n", FILENAME, __FUNCTION__, bSlotIndex); + printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex); std::list::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) { - printf("%s %s bSlotIndex: %d\n", FILENAME, __FUNCTION__, bSlotIndex); + printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex); + std::list::iterator 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) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); return num_slots; } uint32_t cCA::GetNumberSmartCardSlots(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); 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) { + printf("%s -> %s\n", FILENAME, __func__); + std::list::iterator it; bool haveFound = false; @@ -585,9 +589,15 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot) (*it)->cam_caids.clear(); (*it)->newCapmt = false; - (*it)->recordUse = false; - (*it)->liveUse = false; - (*it)->tpid = 0; + (*it)->multi = false; + for (int j = 0; j < CI_MAX_MULTI; j++) + { + (*it)->SID[j] = 0; + (*it)->recordUse[j] = false; + (*it)->liveUse[j] = false; + } + (*it)->TP = 0; + (*it)->ci_use_count = 0; (*it)->pmtlen = 0; (*it)->source = TUNER_A; (*it)->camask = 0; @@ -620,37 +630,43 @@ int cCA::GetCAIDS(CaIdVector &Caids) 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__); std::list::iterator 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; - return true; + if ((*it)->liveUse[j] && (*it)->TP == TP && (*it)->SID[j] == SID && (*it)->source == source && !calen) + { + (*it)->liveUse[j] = false; + return true; + } } } 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__); std::list::iterator 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; - return true; + if ((*it)->recordUse[j] && (*it)->TP == TP && (*it)->SID[j] == SID && (*it)->source == source && !calen) + { + (*it)->recordUse[j] = false; + return true; + } } } 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__); std::list::iterator it; @@ -661,8 +677,14 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned { if (!scrambled) { continue; } - if ((*it)->tpid == tpid && (*it)->source == source) - return it; + for (int j = 0; j < CI_MAX_MULTI; j++) + { + 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) @@ -672,13 +694,13 @@ SlotIt cCA::FindFreeSlot(u64 tpid, u8 source, u16 sid, ca_map_t camap, unsigned if ((*it)->bsids.size()) { 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 ((*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 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 */ -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); + u64 TP = tpid >> 16; unsigned int i = 0; + bool sid_found = false; + //bool recordUse_found = false; printf("%s -> %s\n", FILENAME, __func__); if (!num_slots) return true; /* stb's without ci-slots */ #if x_debug - printf("TPID: %llX\n", tpid); + printf("TP: %llX\n", TP); printf("SID: %04X\n", SID); - printf("SOURCE_DEMUX: %X\n", source_demux); + printf("SOURCE: %X\n", source); printf("CA_MASK: %X\n", camask); printf("CALEN: %d\n", calen); 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 (StopRecordCI(tpid, source_demux, calen)) + if (StopRecordCI(TP, SID, source, calen)) printf("Record CI set free\n"); } else { - if (StopLiveCI(tpid, source_demux, calen)) + if (StopLiveCI(TP, SID, source, calen)) printf("Live CI set free\n"); } } if (calen == 0) return true; - SlotIt It = FindFreeSlot(tpid, source_demux, SID, cm, scrambled); + SlotIt It = FindFreeSlot(TP, source, SID, cm, scrambled); if ((*It)) { printf("Slot: %d\n", (*It)->slot); - - if (enabled) - { - if (mode) - { - if(!checkLiveSlot) - (*It)->liveUse = false; - (*It)->recordUse = true; - } - else if (!(*It)->recordUse) - (*It)->liveUse = true; - } - +/* outcommented, it seems to be not necessary */ +#if 0 SlotIt It2 = GetSlot(!(*It)->slot); 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; else { SendNullPMT((tSlot*)(*It2)); - (*It2)->tpid = 0; (*It2)->scrambled = 0; + (*It2)->TP = 0; + for (int j = 0; j < CI_MAX_MULTI; j++) + (*It2)->SID[j] = 0; } } } - - if ((*It)->tpid != tpid || (*It)->source != source_demux) +#endif + for (int j = 0; j < CI_MAX_MULTI; j++) { - (*It)->tpid = tpid; - (*It)->source = source_demux; + if ((*It)->SID[j] == SID) + 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; for (i = 0; i < calen; i++) (*It)->pmtdata[i] = cabuf[i]; (*It)->newCapmt = true; } else if ((*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed) (*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 { @@ -812,7 +878,7 @@ bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char * cCA::cCA(int Slots) { - printf("%s %s %d\n", FILENAME, __FUNCTION__, Slots); + printf("%s -> %s %d\n", FILENAME, __func__, Slots); int fd, i; char filename[128]; @@ -845,9 +911,15 @@ cCA::cCA(int Slots) slot->mmiOpened = false; slot->newCapmt = false; - slot->recordUse = false; - slot->liveUse = false; - slot->tpid = 0; + slot->multi = false; + for (int j = 0; j < CI_MAX_MULTI; j++) + { + slot->SID[j] = 0; + slot->recordUse[j] = false; + slot->liveUse[j] = false; + } + slot->TP = 0; + slot->ci_use_count = 0; slot->pmtlen = 0; slot->source = TUNER_A; slot->camask = 0; @@ -880,7 +952,7 @@ cCA::cCA(int Slots) cCA::~cCA() { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); } static cCA* pcCAInstance = NULL; @@ -899,7 +971,7 @@ cCA * cCA::GetInstance() cCA::cCA(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); } void cCA::setSource(tSlot* slot) @@ -1160,9 +1232,15 @@ void cCA::slot_pollthread(void *c) slot->cam_caids.clear(); slot->newCapmt = false; - slot->recordUse = false; - slot->liveUse = false; - slot->tpid = 0; + slot->multi = false; + for (int j = 0; j < CI_MAX_MULTI; j++) + { + slot->SID[j] = 0; + slot->recordUse[j] = false; + slot->liveUse[j] = false; + } + slot->TP = 0; + slot->ci_use_count = 0; slot->pmtlen = 0; slot->source = TUNER_A; slot->camask = 0; @@ -1237,13 +1315,13 @@ cCA *CA = cCA::GetInstance(); 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->hasCAManager) { -#if x_debug - printf("buffered capmt(0x%X): > \n", slot->pmtlen); + printf("buffered capmt(%d): > \n", slot->pmtlen); +#if y_debug for (unsigned int i = 0; i < slot->pmtlen; i++) printf("%02X ", slot->pmtdata[i]); printf("\n"); @@ -1263,42 +1341,42 @@ bool cCA::SendCaPMT(tSlot* slot) bool cCA::Init(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); return true; } bool cCA::SendDateTime(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); return false; } bool cCA::Start(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); return true; } void cCA::Stop(void) { - printf("%s %s\n", FILENAME, __FUNCTION__); + printf("%s -> %s\n", FILENAME, __func__); } 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) { - 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) { std::list::iterator 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; } @@ -1327,10 +1405,15 @@ bool cCA::CheckCerts(void) bool cCA::checkChannelID(u64 chanID) { std::list::iterator it; + u16 SID = (u16)(chanID & 0xFFFF); + u64 TP = chanID >> 16; for (it = slot_data.begin(); it != slot_data.end(); ++it) { - if ((*it)->tpid == chanID && !(*it)->SidBlackListed) - return true; + for (int j = 0; j < CI_MAX_MULTI; j++) + { + if ((*it)->TP == TP && (*it)->SID[j] == SID && !(*it)->SidBlackListed) + return true; + } } return false; } diff --git a/common/ca_ci.h b/common/ca_ci.h index 32bd36f..6101f48 100644 --- a/common/ca_ci.h +++ b/common/ca_ci.h @@ -26,6 +26,9 @@ #define T_DATA_LAST 0xA0 // 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 { CA_INIT_SC = 1, CA_INIT_CI, @@ -194,9 +197,12 @@ typedef struct char name[512]; bool newCapmt; - bool recordUse; - bool liveUse; - u64 tpid; + bool multi; + bool recordUse[CI_MAX_MULTI]; + bool liveUse[CI_MAX_MULTI]; + u16 SID[CI_MAX_MULTI]; + u64 TP; + int ci_use_count; u32 pmtlen; u8 source; 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, unsigned char scrambled = 0, ca_map_t camap = std::set(), int mode = 0, bool enabled = false); - bool StopRecordCI( u64 tpid, u8 source, u32 calen); - bool StopLiveCI( u64 tpid, u8 source, u32 calen); + bool StopRecordCI( u64 TP, u16 SID, 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 GetSlot(unsigned int slot); bool SendDateTime(void); diff --git a/libdvbci/dvbci_appmgr.cpp b/libdvbci/dvbci_appmgr.cpp index 1fb2c1b..b0f83bd 100644 --- a/libdvbci/dvbci_appmgr.cpp +++ b/libdvbci/dvbci_appmgr.cpp @@ -43,7 +43,7 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons printf(" application_type: %d\n", ((unsigned char*)data)[0]); 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(" menu string: \n"); + printf(" menu string: "); dl = ((unsigned char*)data)[5]; if ((dl + 6) > len) { @@ -58,7 +58,9 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons printf("\n"); 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; } default: @@ -82,7 +84,7 @@ int eDVBCIApplicationManagerSession::doAction() return 1; } case stateFinal: - printf("in final state."); + printf("%s -> in final state\n", FILENAME); wantmenu = 0; if (wantmenu) { diff --git a/libdvbci/dvbci_ccmgr.cpp b/libdvbci/dvbci_ccmgr.cpp index 9b87df6..459e000 100644 --- a/libdvbci/dvbci_ccmgr.cpp +++ b/libdvbci/dvbci_ccmgr.cpp @@ -1147,7 +1147,11 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_data_req(tSlot *tslot, cons 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 }; uint8_t dest[64]; @@ -1337,7 +1341,11 @@ int eDVBCIContentControlManagerSession::doAction() 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); } diff --git a/libdvbci/dvbci_mmi.cpp b/libdvbci/dvbci_mmi.cpp index 74ee611..94d5b06 100644 --- a/libdvbci/dvbci_mmi.cpp +++ b/libdvbci/dvbci_mmi.cpp @@ -135,11 +135,11 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i if ((d + 3) > max) 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 += eDVBCISession::parseLengthField(d, textlen); - printf("%d bytes text", textlen); + printf("%d bytes text > ", textlen); if ((d + textlen) > max) break; @@ -159,7 +159,8 @@ int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, i { strcpy(listInfo->choice_item[listInfo->choice_nb], str); 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--) printf("%c", *d++); @@ -234,6 +235,8 @@ int eDVBCIMMISession::doAction() int eDVBCIMMISession::stopMMI() { + printf("%s -> %s\n", FILENAME, __func__); + unsigned char tag[] = {0x9f, 0x88, 0x00}; unsigned char data[] = {0x00}; sendAPDU(tag, data, 1); @@ -244,7 +247,7 @@ int eDVBCIMMISession::stopMMI() 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 data[] = {0x00}; @@ -256,7 +259,7 @@ int eDVBCIMMISession::answerText(int answer) 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]; data[0] = 0x01; // answer ok @@ -270,7 +273,7 @@ int eDVBCIMMISession::answerEnq(char * answer, int len) int eDVBCIMMISession::cancelEnq() { - printf("eDVBCIMMISession::cancelEnq()\n"); + printf("%s -> %s\n", FILENAME, __func__); unsigned char tag[] = {0x9f, 0x88, 0x08}; unsigned char data[] = {0x00}; // canceled diff --git a/libdvbci/dvbci_resmgr.cpp b/libdvbci/dvbci_resmgr.cpp index a7c7449..747c3e7 100644 --- a/libdvbci/dvbci_resmgr.cpp +++ b/libdvbci/dvbci_resmgr.cpp @@ -7,22 +7,25 @@ static const char * FILENAME = "[dvbci_resmgr]"; 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); - for (int i = 0; i < len; i++) - printf("%02x ", ((const unsigned char*)data)[i]); - printf("\n"); + if (len) + { + for (int i = 0; i < len; i++) + printf("%02x ", ((const unsigned char*)data)[i]); + printf("\n"); + } if ((tag[0] == 0x9f) && (tag[1] == 0x80)) { switch (tag[2]) { case 0x10: // profile enquiry - printf("cam fragt was ich kann.\n"); + printf("%s -> cam asks what I'm able to\n", FILENAME); state = stateProfileEnquiry; return 1; break; case 0x11: // Tprofile - printf("mein cam kann: "); + printf("%s -> my cam can do: ", FILENAME); if (!len) - printf("nichts\n"); + printf("nothing"); else for (int i = 0; i < len; i++) printf("%02x ", ((const unsigned char*)data)[i]); diff --git a/libdvbci/dvbci_session.cpp b/libdvbci/dvbci_session.cpp index f5a6e38..a48e42b 100644 --- a/libdvbci/dvbci_session.cpp +++ b/libdvbci/dvbci_session.cpp @@ -107,7 +107,7 @@ void eDVBCISession::recvCreateSessionResponse(const unsigned char *data) status = data[0]; state = stateStarted; 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) @@ -115,11 +115,13 @@ void eDVBCISession::recvCloseSessionRequest(const unsigned char *data) status = data[0]; state = stateInDeletion; action = 1; - printf("close Session Request\n"); + printf("%s -> %s\n", FILENAME, __func__); } void eDVBCISession::deleteSessions(const tSlot *slot) { + printf("%s -> %s\n", FILENAME, __func__); + for (unsigned short session_nb = 0; session_nb < SLMS; ++session_nb) { 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 short session_nb; + printf("%s -> %s\n", FILENAME, __func__); + for (session_nb = 1; session_nb < SLMS; ++session_nb) if (!sessions[session_nb - 1]) break; - printf("use session_nb = %d\n", session_nb); + printf("%s -> use session_nb = %d\n", FILENAME, session_nb); if (session_nb == SLMS) { status = 0xF3; @@ -148,7 +152,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re tag |= resource_identifier[2] << 8; tag |= resource_identifier[3]; - printf("Tag: %08lx\n", tag); + printf("Tag: %08lx > ", tag); switch (tag) { @@ -170,14 +174,14 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re printf("DATE-TIME\n"); break; case 0x00400041: + printf("MMI\n"); sessions[session_nb - 1] = new eDVBCIMMISession(slot); - printf("MMI - create session\n"); break; if (cCA::GetInstance()->CheckCerts()) { case 0x008c1001: - sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot); printf("CC MANAGER\n"); + sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot); break; } case 0x00100041: @@ -197,7 +201,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re 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; if (sessions[session_nb - 1]) @@ -235,7 +239,6 @@ int eDVBCISession::pollAll() if (r) { - printf("%s <\n", __func__); return 1; } }