rename tSlot -> eDVBCISlot

Origin commit data
------------------
Branch: master
Commit: 42811846d7
Author: max_10 <max_10@gmx.de>
Date: 2017-10-23 (Mon, 23 Oct 2017)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
max_10
2017-10-23 23:14:22 +02:00
parent 300a4c8216
commit 176cffb538
15 changed files with 152 additions and 160 deletions

View File

@@ -57,7 +57,7 @@ void cs_register_messenger(cs_messenger messenger)
return; return;
} }
bool cCA::checkQueueSize(tSlot* slot) bool cCA::checkQueueSize(eDVBCISlot* slot)
{ {
return (slot->sendqueue.size() > 0); return (slot->sendqueue.size() > 0);
} }
@@ -100,14 +100,15 @@ void cCA::DelTest(int slot)
/* helper function to call the cpp thread loop */ /* helper function to call the cpp thread loop */
void* execute_thread(void *c) void* execute_thread(void *c)
{ {
tSlot* slot = (tSlot*) c; eDVBCISlot* slot = (eDVBCISlot*) c;
cCA *obj = (cCA*)slot->pClass; cCA *obj = (cCA*)slot->pClass;
obj->slot_pollthread(c); obj->slot_pollthread(c);
return NULL; return NULL;
} }
/* from dvb-apps */ /* from dvb-apps */
int asn_1_decode(uint16_t * length, unsigned char * asn_1_array, uint32_t asn_1_array_len) int asn_1_decode(uint16_t * length, unsigned char * asn_1_array,
uint32_t asn_1_array_len)
{ {
uint8_t length_field; uint8_t length_field;
@@ -183,7 +184,7 @@ eData waitData(int fd, unsigned char* buffer, int* len)
return eDataError; return eDataError;
} }
static bool transmitData(tSlot* slot, unsigned char* d, int len) static bool transmitData(eDVBCISlot* slot, unsigned char* d, int len)
{ {
printf("%s -> %s len(%d)\n", FILENAME, __func__, len); printf("%s -> %s len(%d)\n", FILENAME, __func__, len);
@@ -207,7 +208,7 @@ static bool transmitData(tSlot* slot, unsigned char* d, int len)
return true; return true;
} }
static bool sendDataLast(tSlot* slot) static bool sendDataLast(eDVBCISlot* slot)
{ {
unsigned char data[5]; unsigned char data[5];
slot->pollConnection = false; slot->pollConnection = false;
@@ -227,7 +228,7 @@ static bool sendDataLast(tSlot* slot)
return true; return true;
} }
static bool sendRCV(tSlot* slot) static bool sendRCV(eDVBCISlot* slot)
{ {
unsigned char send_data[5]; unsigned char send_data[5];
slot->pollConnection = false; slot->pollConnection = false;
@@ -295,7 +296,7 @@ eData sendData(tSlot* slot, unsigned char* data, int len)
} }
//send a transport connection create request //send a transport connection create request
bool sendCreateTC(tSlot* slot) bool sendCreateTC(eDVBCISlot* slot)
{ {
unsigned char data[5]; unsigned char data[5];
data[0] = slot->slot; data[0] = slot->slot;
@@ -311,7 +312,7 @@ bool sendCreateTC(tSlot* slot)
return true; return true;
} }
void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int /*con_id*/) void cCA::process_tpdu(eDVBCISlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int /*con_id*/)
{ {
switch (tpdu_tag) switch (tpdu_tag)
{ {
@@ -432,7 +433,7 @@ void cCA::MenuEnter(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
{ {
printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
@@ -460,7 +461,7 @@ void cCA::MenuAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint32_t choice)
{ {
printf("%s -> %s Slot(%d) choice(%d)\n", FILENAME, __func__, bSlotIndex, choice); printf("%s -> %s Slot(%d) choice(%d)\n", FILENAME, __func__, bSlotIndex, choice);
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
@@ -476,7 +477,7 @@ void cCA::InputAnswer(enum CA_SLOT_TYPE, uint32_t bSlotIndex, uint8_t * pBuffer,
{ {
printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
@@ -493,7 +494,7 @@ void cCA::MenuClose(enum CA_SLOT_TYPE, uint32_t bSlotIndex)
{ {
printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex); printf("%s -> %s Slot(%d)\n", FILENAME, __func__, bSlotIndex);
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
@@ -520,7 +521,7 @@ uint32_t cCA::GetNumberSmartCardSlots(void)
void cCA::ModuleName(enum CA_SLOT_TYPE, uint32_t slot, char * Name) void cCA::ModuleName(enum CA_SLOT_TYPE, uint32_t slot, char * Name)
{ {
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::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) if ((*it)->slot == slot)
@@ -533,7 +534,7 @@ void cCA::ModuleName(enum CA_SLOT_TYPE, uint32_t slot, char * Name)
bool cCA::ModulePresent(enum CA_SLOT_TYPE, uint32_t slot) bool cCA::ModulePresent(enum CA_SLOT_TYPE, uint32_t slot)
{ {
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
@@ -550,7 +551,7 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
bool haveFound = false; bool haveFound = false;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
@@ -566,8 +567,8 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
(*it)->status = eStatusReset; (*it)->status = eStatusReset;
usleep(200000); usleep(200000);
if ((*it)->hasCCManager) if ((*it)->hasCCManager)
(*it)->ccmgrSession->ci_ccmgr_doClose((tSlot*)(*it)); (*it)->ccmgrSession->ci_ccmgr_doClose((eDVBCISlot*)(*it));
eDVBCISession::deleteSessions((tSlot*)(*it)); eDVBCISession::deleteSessions((eDVBCISlot*)(*it));
(*it)->mmiSession = NULL; (*it)->mmiSession = NULL;
(*it)->hasMMIManager = false; (*it)->hasMMIManager = false;
(*it)->hasCAManager = false; (*it)->hasCAManager = false;
@@ -619,7 +620,7 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
int cCA::GetCAIDS(CaIdVector &Caids) int cCA::GetCAIDS(CaIdVector &Caids)
{ {
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
if ((*it)->camIsReady) if ((*it)->camIsReady)
@@ -634,7 +635,7 @@ int cCA::GetCAIDS(CaIdVector &Caids)
bool cCA::StopLiveCI( u64 TP, u16 SID, 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<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
for (int j = 0; j < CI_MAX_MULTI; j++) for (int j = 0; j < CI_MAX_MULTI; j++)
@@ -652,7 +653,7 @@ bool cCA::StopLiveCI( u64 TP, u16 SID, u8 source, u32 calen)
bool cCA::StopRecordCI( u64 TP, u16 SID, 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<eDVBCISlot*>::iterator it;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)
{ {
for (int j = 0; j < CI_MAX_MULTI; j++) for (int j = 0; j < CI_MAX_MULTI; j++)
@@ -670,7 +671,7 @@ bool cCA::StopRecordCI( u64 TP, u16 SID, u8 source, u32 calen)
SlotIt cCA::FindFreeSlot(u64 TP, 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<eDVBCISlot*>::iterator it;
ca_map_iterator_t caIt; ca_map_iterator_t caIt;
unsigned int i; unsigned int i;
int count = 0; int count = 0;
@@ -741,7 +742,7 @@ SlotIt cCA::FindFreeSlot(u64 TP, u8 source, u16 SID, ca_map_t camap, unsigned ch
{ {
if ((*it)->source == source && (!checkLiveSlot || !liveUse_found)) if ((*it)->source == source && (!checkLiveSlot || !liveUse_found))
{ {
SendNullPMT((tSlot*)(*it)); SendNullPMT((eDVBCISlot*)(*it));
(*it)->SidBlackListed = true; (*it)->SidBlackListed = true;
for (int j = 0; j < CI_MAX_MULTI; j++) for (int j = 0; j < CI_MAX_MULTI; j++)
(*it)->SID[j] = 0; (*it)->SID[j] = 0;
@@ -844,7 +845,7 @@ bool cCA::SendCAPMT(u64 tpid, u8 source, u8 camask, const unsigned char * cabuf,
} }
else else
{ {
SendNullPMT((tSlot*)(*It2)); SendNullPMT((eDVBCISlot*)(*It2));
(*It2)->scrambled = 0; (*It2)->scrambled = 0;
(*It2)->TP = 0; (*It2)->TP = 0;
for (int j = 0; j < CI_MAX_MULTI; j++) for (int j = 0; j < CI_MAX_MULTI; j++)
@@ -911,7 +912,7 @@ bool cCA::SendCAPMT(u64 tpid, u8 source, u8 camask, const unsigned char * cabuf,
} }
if (!(*It)->newCapmt && (*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed) if (!(*It)->newCapmt && (*It)->ccmgr_ready && (*It)->hasCCManager && (*It)->scrambled && !(*It)->SidBlackListed)
(*It)->ccmgrSession->resendKey((tSlot*)(*It)); (*It)->ccmgrSession->resendKey((eDVBCISlot*)(*It));
} }
else else
@@ -952,7 +953,7 @@ cCA::cCA(int Slots)
{ {
printf("failed to open %s ->%m", filename); printf("failed to open %s ->%m", filename);
} }
tSlot* slot = (tSlot*) malloc(sizeof(tSlot)); eDVBCISlot* slot = (eDVBCISlot*) malloc(sizeof(eDVBCISlot));
slot->slot = i; slot->slot = i;
slot->fd = fd; slot->fd = fd;
slot->connection_id = 0; slot->connection_id = 0;
@@ -1034,7 +1035,7 @@ cCA::cCA(void)
printf("%s -> %s\n", FILENAME, __func__); printf("%s -> %s\n", FILENAME, __func__);
} }
void cCA::setSource(tSlot* slot) void cCA::setSource(eDVBCISlot* slot)
{ {
char buf[64]; char buf[64];
snprintf(buf, 64, "/proc/stb/tsmux/ci%d_input", slot->slot); snprintf(buf, 64, "/proc/stb/tsmux/ci%d_input", slot->slot);
@@ -1065,7 +1066,7 @@ void cCA::slot_pollthread(void *c)
{ {
ca_slot_info_t info; ca_slot_info_t info;
unsigned char data[1024 * 4]; unsigned char data[1024 * 4];
tSlot* slot = (tSlot*) c; eDVBCISlot* slot = (eDVBCISlot*) c;
while (1) while (1)
{ {
@@ -1373,7 +1374,7 @@ void cCA::slot_pollthread(void *c)
cCA *CA = cCA::GetInstance(); cCA *CA = cCA::GetInstance();
bool cCA::SendCaPMT(tSlot* slot) bool cCA::SendCaPMT(eDVBCISlot* 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))
@@ -1434,14 +1435,14 @@ void cCA::SetInitMask(enum CA_INIT_MASK p)
SlotIt cCA::GetSlot(unsigned int slot) SlotIt cCA::GetSlot(unsigned int slot)
{ {
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::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)->init) if ((*it)->slot == slot && (*it)->init)
return it; return it;
return it; return it;
} }
bool cCA::SendNullPMT(tSlot* slot) bool cCA::SendNullPMT(eDVBCISlot* slot)
{ {
printf("%s > %s >**\n", FILENAME, __func__); printf("%s > %s >**\n", FILENAME, __func__);
if ((slot->fd > 0) && (slot->camIsReady) && (slot->hasCAManager)) if ((slot->fd > 0) && (slot->camIsReady) && (slot->hasCAManager))
@@ -1464,7 +1465,7 @@ bool cCA::CheckCerts(void)
bool cCA::checkChannelID(u64 chanID) bool cCA::checkChannelID(u64 chanID)
{ {
std::list<tSlot*>::iterator it; std::list<eDVBCISlot*>::iterator it;
u16 SID = (u16)(chanID & 0xFFFF); u16 SID = (u16)(chanID & 0xFFFF);
u64 TP = chanID >> 16; u64 TP = chanID >> 16;
for (it = slot_data.begin(); it != slot_data.end(); ++it) for (it = slot_data.begin(); it != slot_data.end(); ++it)

View File

@@ -222,11 +222,11 @@ typedef struct
/* private data */ /* private data */
void *private_data; void *private_data;
} tSlot; } eDVBCISlot;
eData sendData(tSlot *slot, unsigned char* data, int len); eData sendData(eDVBCISlot *slot, unsigned char* data, int len);
typedef std::list<tSlot*>::iterator SlotIt; typedef std::list<eDVBCISlot*>::iterator SlotIt;
/// CA module class /// CA module class
class cCA { class cCA {
@@ -242,7 +242,7 @@ private:
bool init; bool init;
void SendPMT(); void SendPMT();
pthread_mutex_t ciMutex; pthread_mutex_t ciMutex;
std::list<tSlot*> slot_data; std::list<eDVBCISlot*> slot_data;
pthread_t slot_thread; pthread_t slot_thread;
public: public:
@@ -296,15 +296,15 @@ public:
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);
bool SendCaPMT(tSlot* slot); bool SendCaPMT(eDVBCISlot* slot);
void slot_pollthread(void *c); void slot_pollthread(void *c);
void setSource(tSlot* slot); void setSource(eDVBCISlot* slot);
bool checkQueueSize(tSlot* slot); bool checkQueueSize(eDVBCISlot* slot);
void process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int con_id); void process_tpdu(eDVBCISlot* slot, unsigned char tpdu_tag, __u8* data, int asn_data_length, int con_id);
bool checkChannelID(u64 chanID); bool checkChannelID(u64 chanID);
void setCheckLiveSlot(int check); void setCheckLiveSlot(int check);
bool SendNullPMT(tSlot* slot); bool SendNullPMT(eDVBCISlot* slot);
bool CheckCerts(void); bool CheckCerts(void);
void Test(int slot, CaIdVector caids); void Test(int slot, CaIdVector caids);
void DelTest(int slot); void DelTest(int slot);

View File

@@ -7,11 +7,9 @@
#include "dvbci_appmgr.h" #include "dvbci_appmgr.h"
/* prevent possibly segfaults: read at end of this file */ /* prevent possibly segfaults: read at end of this file */
#define yy_debug 0 #define yy_debug 0
static const char * FILENAME = "[dvbci_appmgr]"; eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(eDVBCISlot *tslot)
eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(tSlot *tslot)
{ {
slot = tslot; slot = tslot;
slot->hasAppManager = true; slot->hasAppManager = true;
@@ -26,7 +24,7 @@ eDVBCIApplicationManagerSession::~eDVBCIApplicationManagerSession()
int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]); printf("[CI AM] SESSION(%d)/APP %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
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]);
printf("\n"); printf("\n");
@@ -38,16 +36,16 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons
case 0x21: case 0x21:
{ {
int dl; int dl;
printf("application info:\n"); printf("[CI AM] application info:\n");
printf(" len: %d\n", len); printf("[CI AM] len: %d\n", len);
printf(" application_type: %d\n", ((unsigned char*)data)[0]); printf("[CI AM] application_type: %d\n", ((unsigned char*)data)[0]);
printf(" application_manufacturer: %02x %02x\n", ((unsigned char*)data)[2], ((unsigned char*)data)[1]); printf("[CI AM] 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("[CI AM] manufacturer_code: %02x %02x\n", ((unsigned char*)data)[4], ((unsigned char*)data)[3]);
printf(" menu string: "); printf(" menu string: ");
dl = ((unsigned char*)data)[5]; dl = ((unsigned char*)data)[5];
if ((dl + 6) > len) if ((dl + 6) > len)
{ {
printf("warning, invalid length (%d vs %d)\n", dl + 6, len); printf("[CI AM] warning, invalid length (%d vs %d)\n", dl + 6, len);
dl = len - 6; dl = len - 6;
} }
char str[dl + 1]; char str[dl + 1];
@@ -60,11 +58,11 @@ int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag, cons
strcpy(slot->name, str); strcpy(slot->name, str);
if (!strcmp(slot->name, "AlphaCrypt")) if (!strcmp(slot->name, "AlphaCrypt"))
slot->multi = true; slot->multi = true;
printf("%s set cam name %s on slot(%d)\n", FILENAME, slot->name, slot->slot); printf("[CI AM] set cam name %s on slot(%d)\n", slot->name, slot->slot);
break; break;
} }
default: default:
printf("%s unknown APDU tag 9F 80 %02x\n", FILENAME, tag[2]); printf("[CI AM] unknown APDU tag 9F 80 %02x\n", tag[2]);
break; break;
} }
} }
@@ -77,19 +75,19 @@ int eDVBCIApplicationManagerSession::doAction()
{ {
case stateStarted: case stateStarted:
{ {
const unsigned char tag[3] = {0x9F, 0x80, 0x20}; const unsigned char tag[3] = {0x9F, 0x80, 0x20}; // application manager info e sendAPDU(tag);
sendAPDU(tag); sendAPDU(tag);
state = stateFinal; state = stateFinal;
checkBlist(); checkBlist();
return 1; return 1;
} }
case stateFinal: case stateFinal:
printf("%s -> in final state\n", FILENAME); printf("[CI AM] in final state.");
wantmenu = 0; wantmenu = 0;
if (wantmenu) if (wantmenu)
{ {
printf("%s wantmenu: sending Tenter_menu\n", FILENAME); printf("[CI AM] wantmenu: sending Tenter_menu");
const unsigned char tag[3] = {0x9F, 0x80, 0x22}; const unsigned char tag[3] = {0x9F, 0x80, 0x22}; // Tenter_menu
sendAPDU(tag); sendAPDU(tag);
wantmenu = 0; wantmenu = 0;
return 0; return 0;
@@ -103,8 +101,8 @@ int eDVBCIApplicationManagerSession::doAction()
int eDVBCIApplicationManagerSession::startMMI() int eDVBCIApplicationManagerSession::startMMI()
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("[CI AM] in appmanager -> startmmi()");
const unsigned char tag[3] = {0x9F, 0x80, 0x22}; const unsigned char tag[3] = {0x9F, 0x80, 0x22}; // Tenter_menu
sendAPDU(tag); sendAPDU(tag);
slot->mmiOpened = true; slot->mmiOpened = true;
return 0; return 0;

View File

@@ -9,7 +9,7 @@ class eDVBCIApplicationManagerSession: public eDVBCISession
stateFinal=statePrivate stateFinal=statePrivate
}; };
tSlot *slot; eDVBCISlot *slot;
int wantmenu; int wantmenu;
int receivedAPDU(const unsigned char *tag, const void *data, int len); int receivedAPDU(const unsigned char *tag, const void *data, int len);
@@ -17,7 +17,7 @@ class eDVBCIApplicationManagerSession: public eDVBCISession
bool readBlist(); bool readBlist();
int checkBlist(); int checkBlist();
public: public:
eDVBCIApplicationManagerSession(tSlot *tslot); eDVBCIApplicationManagerSession(eDVBCISlot *tslot);
~eDVBCIApplicationManagerSession(); ~eDVBCIApplicationManagerSession();
int enterMenu(); int enterMenu();
int startMMI(); int startMMI();

View File

@@ -1,12 +1,11 @@
/* DVB CI CA Manager */ /* DVB CI CA Manager */
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm>
#include "dvbci_camgr.h" #include "dvbci_camgr.h"
#include <algorithm> eDVBCICAManagerSession::eDVBCICAManagerSession(eDVBCISlot *tslot)
eDVBCICAManagerSession::eDVBCICAManagerSession(tSlot *tslot)
{ {
slot = tslot; slot = tslot;
} }
@@ -19,7 +18,7 @@ eDVBCICAManagerSession::~eDVBCICAManagerSession()
int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)/CA %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]); printf("[CI CA] SESSION(%d)/CA %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
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]);
printf("\n"); printf("\n");
@@ -30,7 +29,7 @@ int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *d
{ {
case 0x31: case 0x31:
{ {
printf("ca info:\n"); printf("[CI CA] ca info:\n");
for (int i = 0; i < len; i += 2) for (int i = 0; i < len; i += 2)
{ {
printf("%04x ", (((const unsigned char*)data)[i] << 8) | (((const unsigned char*)data)[i + 1])); printf("%04x ", (((const unsigned char*)data)[i] << 8) | (((const unsigned char*)data)[i + 1]));
@@ -51,7 +50,7 @@ int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *d
} }
break; break;
default: default:
printf("unknown APDU tag 9F 80 %02x\n", tag[2]); printf("[CI CA] unknown APDU tag 9F 80 %02x\n", tag[2]);
break; break;
} }
} }
@@ -70,7 +69,7 @@ int eDVBCICAManagerSession::doAction()
return 0; return 0;
} }
case stateFinal: case stateFinal:
printf("stateFinal und action! kann doch garnicht sein ;)\n"); printf("[CI CA] stateFinal and action should not happen\n");
default: default:
return 0; return 0;
} }

View File

@@ -14,7 +14,7 @@ class eDVBCICAManagerSession: public eDVBCISession
int receivedAPDU(const unsigned char *tag, const void *data, int len); int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction(); int doAction();
public: public:
eDVBCICAManagerSession(tSlot *tslot); eDVBCICAManagerSession(eDVBCISlot *tslot);
~eDVBCICAManagerSession(); ~eDVBCICAManagerSession();
const std::vector<uint16_t> &getCAIDs() const { return caids; } const std::vector<uint16_t> &getCAIDs() const { return caids; }

View File

@@ -333,7 +333,7 @@ struct element {
struct cc_ctrl_data { struct cc_ctrl_data {
/* parent */ /* parent */
//struct ci_session *session; //struct ci_session *session;
tSlot *slot; eDVBCISlot *slot;
/* ci+ credentials */ /* ci+ credentials */
struct element elements[MAX_ELEMENTS]; struct element elements[MAX_ELEMENTS];
@@ -1039,7 +1039,7 @@ static int data_req_loop(struct cc_ctrl_data *cc_data, unsigned char *dest, cons
return pos; return pos;
} }
bool eDVBCIContentControlManagerSession::data_initialize(tSlot *tslot) bool eDVBCIContentControlManagerSession::data_initialize(eDVBCISlot *tslot)
{ {
struct cc_ctrl_data *data; struct cc_ctrl_data *data;
uint8_t buf[32], host_id[8]; uint8_t buf[32], host_id[8];
@@ -1093,7 +1093,7 @@ bool eDVBCIContentControlManagerSession::data_initialize(tSlot *tslot)
return true; return true;
} }
void eDVBCIContentControlManagerSession::ci_ccmgr_cc_open_cnf(tSlot *tslot) void eDVBCIContentControlManagerSession::ci_ccmgr_cc_open_cnf(eDVBCISlot *tslot)
{ {
const uint8_t tag[3] = { 0x9f, 0x90, 0x02 }; const uint8_t tag[3] = { 0x9f, 0x90, 0x02 };
const uint8_t bitmap = 0x01; const uint8_t bitmap = 0x01;
@@ -1104,7 +1104,7 @@ void eDVBCIContentControlManagerSession::ci_ccmgr_cc_open_cnf(tSlot *tslot)
sendAPDU(tag, &bitmap, 1); sendAPDU(tag, &bitmap, 1);
} }
bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_data_req(tSlot *tslot, const uint8_t *data, unsigned int len) bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_data_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int len)
{ {
struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data); struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data);
uint8_t cc_data_cnf_tag[3] = { 0x9f, 0x90, 0x04 }; uint8_t cc_data_cnf_tag[3] = { 0x9f, 0x90, 0x04 };
@@ -1147,7 +1147,7 @@ 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 void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_sync_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int
#if y_debug #if y_debug
len len
#endif #endif
@@ -1183,7 +1183,7 @@ void eDVBCIContentControlManagerSession::ci_ccmgr_cc_sync_req()
sendAPDU(tag, &sync_req_status, 1); sendAPDU(tag, &sync_req_status, 1);
} }
bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_send(tSlot *tslot, const uint8_t *tag, uint8_t *data, unsigned int pos) bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_send(eDVBCISlot *tslot, const uint8_t *tag, uint8_t *data, unsigned int pos)
{ {
struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data); struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data);
printf("%s -> %s (%02X%02X%02X) \n", FILENAME, __FUNCTION__, tag[0], tag[1], tag[2]); printf("%s -> %s (%02X%02X%02X) \n", FILENAME, __FUNCTION__, tag[0], tag[1], tag[2]);
@@ -1207,7 +1207,7 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_send(tSlot *tslot, cons
return true; return true;
} }
bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_data_req(tSlot *tslot, const uint8_t *data, unsigned int len) bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_data_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int len)
{ {
struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data); struct cc_ctrl_data *cc_data = (struct cc_ctrl_data*)(tslot->private_data);
const uint8_t data_cnf_tag[3] = { 0x9f, 0x90, 0x08 }; const uint8_t data_cnf_tag[3] = { 0x9f, 0x90, 0x08 };
@@ -1270,7 +1270,7 @@ bool eDVBCIContentControlManagerSession::ci_ccmgr_cc_sac_data_req(tSlot *tslot,
return ci_ccmgr_cc_sac_send(tslot, data_cnf_tag, dest, pos); return ci_ccmgr_cc_sac_send(tslot, data_cnf_tag, dest, pos);
} }
eDVBCIContentControlManagerSession::eDVBCIContentControlManagerSession(tSlot *tslot) eDVBCIContentControlManagerSession::eDVBCIContentControlManagerSession(eDVBCISlot *tslot)
{ {
slot = tslot; slot = tslot;
slot->hasCCManager = true; slot->hasCCManager = true;
@@ -1284,7 +1284,7 @@ eDVBCIContentControlManagerSession::~eDVBCIContentControlManagerSession()
slot->ccmgrSession = NULL; slot->ccmgrSession = NULL;
} }
void eDVBCIContentControlManagerSession::ci_ccmgr_doClose(tSlot *tslot) void eDVBCIContentControlManagerSession::ci_ccmgr_doClose(eDVBCISlot *tslot)
{ {
struct cc_ctrl_data *data = (struct cc_ctrl_data*)(tslot->private_data); struct cc_ctrl_data *data = (struct cc_ctrl_data*)(tslot->private_data);
printf("%s -> %s\n", FILENAME, __FUNCTION__); printf("%s -> %s\n", FILENAME, __FUNCTION__);
@@ -1339,12 +1339,13 @@ int eDVBCIContentControlManagerSession::doAction()
} }
} }
void eDVBCIContentControlManagerSession::resendKey(tSlot *tslot) void eDVBCIContentControlManagerSession::resendKey(eDVBCISlot *tslot)
{ {
/* Fix me ! no ci* cam with multi decrypt is known /* Fix me ! no ci* cam with multi decrypt is known
* therefore for now it is OK to use element [0] * therefore for now it is OK to use element [0]
* in bool arrays */ * in bool arrays
*/
if (!tslot->SidBlackListed && (tslot->recordUse[0] || tslot->liveUse[0])) 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

@@ -5,13 +5,13 @@
class eDVBCIContentControlManagerSession: public eDVBCISession class eDVBCIContentControlManagerSession: public eDVBCISession
{ {
bool data_initialize(tSlot *tslot); bool data_initialize(eDVBCISlot *tslot);
bool ci_ccmgr_cc_data_req(tSlot *tslot, const uint8_t *data, unsigned int len); bool ci_ccmgr_cc_data_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int len);
bool ci_ccmgr_cc_sac_data_req(tSlot *tslot, const uint8_t *data, unsigned int len); bool ci_ccmgr_cc_sac_data_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int len);
bool ci_ccmgr_cc_sac_send(tSlot *tslot, const uint8_t *tag, uint8_t *data, unsigned int pos); bool ci_ccmgr_cc_sac_send(eDVBCISlot *tslot, const uint8_t *tag, uint8_t *data, unsigned int pos);
void ci_ccmgr_cc_sac_sync_req(tSlot *tslot, const uint8_t *data, unsigned int len); void ci_ccmgr_cc_sac_sync_req(eDVBCISlot *tslot, const uint8_t *data, unsigned int len);
void ci_ccmgr_cc_sync_req(); void ci_ccmgr_cc_sync_req();
void ci_ccmgr_cc_open_cnf(tSlot *slot); void ci_ccmgr_cc_open_cnf(eDVBCISlot *slot);
enum { enum {
stateFinal=statePrivate stateFinal=statePrivate
@@ -19,9 +19,9 @@ class eDVBCIContentControlManagerSession: public eDVBCISession
int receivedAPDU(const unsigned char *tag, const void *data, int len); int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction(); int doAction();
public: public:
eDVBCIContentControlManagerSession(tSlot *tslot); eDVBCIContentControlManagerSession(eDVBCISlot *tslot);
~eDVBCIContentControlManagerSession(); ~eDVBCIContentControlManagerSession();
void ci_ccmgr_doClose(tSlot *tslot); void ci_ccmgr_doClose(eDVBCISlot *tslot);
void resendKey(tSlot *tslot); void resendKey(eDVBCISlot *tslot);
}; };
#endif #endif

View File

@@ -6,9 +6,7 @@
#include "dvbci_datetimemgr.h" #include "dvbci_datetimemgr.h"
static const char * FILENAME = "[dvbci_datetimemgr]"; eDVBCIDateTimeSession::eDVBCIDateTimeSession(eDVBCISlot *tslot)
eDVBCIDateTimeSession::eDVBCIDateTimeSession(tSlot *tslot)
{ {
slot = tslot; slot = tslot;
slot->hasDateTime = true; slot->hasDateTime = true;
@@ -22,7 +20,7 @@ eDVBCIDateTimeSession::~eDVBCIDateTimeSession()
int eDVBCIDateTimeSession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCIDateTimeSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)/DATETIME %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]); printf("[CI DT] SESSION(%d)/DATETIME %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
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]);
printf("\n"); printf("\n");
@@ -36,7 +34,7 @@ int eDVBCIDateTimeSession::receivedAPDU(const unsigned char *tag, const void *da
return 1; return 1;
break; break;
default: default:
printf("unknown APDU tag 9F 84 %02x\n", tag[2]); printf("[CI DT] unknown APDU tag 9F 84 %02x\n", tag[2]);
break; break;
} }
} }

View File

@@ -11,7 +11,7 @@ class eDVBCIDateTimeSession: public eDVBCISession
int receivedAPDU(const unsigned char *tag, const void *data, int len); int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction(); int doAction();
public: public:
eDVBCIDateTimeSession(tSlot *tslot); eDVBCIDateTimeSession(eDVBCISlot *tslot);
~eDVBCIDateTimeSession(); ~eDVBCIDateTimeSession();
}; };

View File

@@ -7,11 +7,8 @@
#include "dvbci_mmi.h" #include "dvbci_mmi.h"
#include <ca_cs.h> #include <ca_cs.h>
static const char * FILENAME = "[dvbci_mmi]"; eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot)
eDVBCIMMISession::eDVBCIMMISession(tSlot *tslot)
{ {
printf("%s -> %s\n", FILENAME, __func__);
slot = tslot; slot = tslot;
slot->hasMMIManager = true; slot->hasMMIManager = true;
slot->mmiSession = this; slot->mmiSession = this;
@@ -35,7 +32,7 @@ eDVBCIMMISession::~eDVBCIMMISession()
int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len) int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{ {
printf("SESSION(%d)/MMI %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]); printf("[CI MMI] SESSION(%d)/MMI %02x %02x %02x: ", session_nb, tag[0], tag[1], tag[2]);
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]);
printf("\n"); printf("\n");
@@ -235,7 +232,7 @@ int eDVBCIMMISession::doAction()
int eDVBCIMMISession::stopMMI() int eDVBCIMMISession::stopMMI()
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("[CI MMI] eDVBCIMMISession::stopMMI()\n");
unsigned char tag[] = {0x9f, 0x88, 0x00}; unsigned char tag[] = {0x9f, 0x88, 0x00};
unsigned char data[] = {0x00}; unsigned char data[] = {0x00};
@@ -247,7 +244,7 @@ int eDVBCIMMISession::stopMMI()
int eDVBCIMMISession::answerText(int answer) int eDVBCIMMISession::answerText(int answer)
{ {
printf("%s -> %s(%d)\n", FILENAME, __func__, answer); printf("[CI MMI] eDVBCIMMISession::answerText(%d)\n",answer);
unsigned char tag[] = {0x9f, 0x88, 0x0B}; unsigned char tag[] = {0x9f, 0x88, 0x0B};
unsigned char data[] = {0x00}; unsigned char data[] = {0x00};
@@ -257,9 +254,9 @@ int eDVBCIMMISession::answerText(int answer)
return 0; return 0;
} }
int eDVBCIMMISession::answerEnq(char * answer, int len) int eDVBCIMMISession::answerEnq(char *answer, int len)
{ {
printf("%s -> %s(%d bytes)\n", FILENAME, __func__, len); printf("[CI MMI] eDVBCIMMISession::answerEnq(%d bytes)\n", len);
unsigned char data[len + 1]; unsigned char data[len + 1];
data[0] = 0x01; // answer ok data[0] = 0x01; // answer ok
@@ -273,7 +270,7 @@ int eDVBCIMMISession::answerEnq(char * answer, int len)
int eDVBCIMMISession::cancelEnq() int eDVBCIMMISession::cancelEnq()
{ {
printf("%s -> %s\n", FILENAME, __func__); printf("[CI MMI] eDVBCIMMISession::cancelEnq()\n");
unsigned char tag[] = {0x9f, 0x88, 0x08}; unsigned char tag[] = {0x9f, 0x88, 0x08};
unsigned char data[] = {0x00}; // canceled unsigned char data[] = {0x00}; // canceled

View File

@@ -11,9 +11,9 @@ class eDVBCIMMISession: public eDVBCISession
int receivedAPDU(const unsigned char *tag, const void *data, int len); int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction(); int doAction();
tSlot *slot; eDVBCISlot *slot;
public: public:
eDVBCIMMISession(tSlot *tslot); eDVBCIMMISession(eDVBCISlot *tslot);
~eDVBCIMMISession(); ~eDVBCIMMISession();
int stopMMI(); int stopMMI();
int answerText(int answer); int answerText(int answer);

View File

@@ -1,12 +1,11 @@
/* DVB CI Resource Manager */ /* DVB CI Resource Manager */
#include <stdio.h> #include <stdio.h>
#include "dvbci_resmgr.h" #include "dvbci_resmgr.h"
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("[CI RM] SESSION(%d)RES %02x %02x %02x (len = %d): \n", session_nb, tag[0], tag[1], tag[2], len);
if (len) if (len)
{ {
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
@@ -18,12 +17,12 @@ int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const v
switch (tag[2]) switch (tag[2])
{ {
case 0x10: // profile enquiry case 0x10: // profile enquiry
printf("%s -> cam asks what I'm able to\n", FILENAME); printf("[CI RM] cam profile inquiry\n");
state = stateProfileEnquiry; state = stateProfileEnquiry;
return 1; return 1;
break; break;
case 0x11: // Tprofile case 0x11: // Tprofile
printf("%s -> my cam can do: ", FILENAME); printf("[CI RM] -> my cam can do: ");
if (!len) if (!len)
printf("nothing"); printf("nothing");
else else
@@ -39,9 +38,10 @@ int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const v
state = stateFinal; state = stateFinal;
break; break;
default: default:
printf("%s %s unknown APDU tag 9F 80 %02x\n", FILENAME, __FUNCTION__, tag[2]); printf("[CI RM] unknown APDU tag 9F 80 %02x\n", tag[2]);
} }
} }
return 0; return 0;
} }
@@ -66,7 +66,7 @@ int eDVBCIResourceManagerSession::doAction()
} }
case stateProfileChange: case stateProfileChange:
{ {
printf("bla kaputt\n"); printf("[CI RM] cannot deal with statProfileChange\n");
break; break;
} }
case stateProfileEnquiry: case stateProfileEnquiry:
@@ -108,7 +108,7 @@ int eDVBCIResourceManagerSession::doAction()
return 0; return 0;
} }
case stateFinal: case stateFinal:
printf("stateFinal und action! kann doch garnicht sein ;)\n"); printf("[CI RM] Should not happen: action on stateFinal\n");
default: default:
break; break;
} }

View File

@@ -1,4 +1,5 @@
/* DVB CI Transport Connection */ /* DVB CI Transport Connection */
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -11,8 +12,6 @@
#include "dvbci_mmi.h" #include "dvbci_mmi.h"
#include "dvbci_ccmgr.h" #include "dvbci_ccmgr.h"
static const char * FILENAME = "[dvbci_session]";
eDVBCISession* eDVBCISession::sessions[SLMS]; eDVBCISession* eDVBCISession::sessions[SLMS];
int eDVBCISession::buildLengthField(unsigned char *pkt, int len) int eDVBCISession::buildLengthField(unsigned char *pkt, int len)
@@ -94,10 +93,11 @@ void eDVBCISession::sendSPDU(tSlot *slot, unsigned char tag, const void *data, i
sendData(slot, pkt, ptr - pkt); sendData(slot, pkt, ptr - pkt);
} }
void eDVBCISession::sendOpenSessionResponse(tSlot *slot, unsigned char session_status, const unsigned char *resource_identifier, unsigned short session_nb) void eDVBCISession::sendOpenSessionResponse(eDVBCISlot *slot, unsigned char session_status, const unsigned char *resource_identifier, unsigned short session_nb)
{ {
char pkt[6]; char pkt[6];
pkt[0] = session_status; pkt[0] = session_status;
printf("[CI SESS] sendOpenSessionResponse");
memcpy(pkt + 1, resource_identifier, 4); memcpy(pkt + 1, resource_identifier, 4);
sendSPDU(slot, 0x92, pkt, 5, session_nb); sendSPDU(slot, 0x92, pkt, 5, session_nb);
} }
@@ -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("%s -> %s status(%x)\n", FILENAME, __func__, status); printf("[CI SESS] create Session Response, status %x\n", status);
} }
void eDVBCISession::recvCloseSessionRequest(const unsigned char *data) void eDVBCISession::recvCloseSessionRequest(const unsigned char *data)
@@ -115,13 +115,11 @@ void eDVBCISession::recvCloseSessionRequest(const unsigned char *data)
status = data[0]; status = data[0];
state = stateInDeletion; state = stateInDeletion;
action = 1; action = 1;
printf("%s -> %s\n", FILENAME, __func__); printf("[CI SESS] close Session Request\n");
} }
void eDVBCISession::deleteSessions(const tSlot *slot) void eDVBCISession::deleteSessions(const eDVBCISlot *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)
@@ -129,18 +127,16 @@ void eDVBCISession::deleteSessions(const tSlot *slot)
} }
} }
eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *resource_identifier, unsigned char &status) eDVBCISession* eDVBCISession::createSession(eDVBCISlot *slot, const unsigned char *resource_identifier, unsigned char &status)
{ {
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("%s -> use session_nb = %d\n", FILENAME, session_nb); printf("[CI SESS] -> use session_nb = %d\n", session_nb);
if (session_nb == SLMS) if (session_nb == SLMS)
{ {
status = 0xF3; status = 0xF3;
@@ -152,56 +148,56 @@ 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 > ", tag); printf("[CI SESS] Tag: %08lx > ", tag);
switch (tag) switch (tag)
{ {
case 0x00010041: case 0x00010041:
sessions[session_nb - 1] = new eDVBCIResourceManagerSession; sessions[session_nb - 1] = new eDVBCIResourceManagerSession;
printf("RESOURCE MANAGER\n"); printf("[CI SESS] RESOURCE MANAGER\n");
break; break;
case 0x00020041: case 0x00020041:
case 0x00020043: case 0x00020043:
sessions[session_nb - 1] = new eDVBCIApplicationManagerSession(slot); sessions[session_nb - 1] = new eDVBCIApplicationManagerSession(slot);
printf("APPLICATION MANAGER\n"); printf("[CI SESS] APPLICATION MANAGER\n");
break; break;
case 0x00030041: case 0x00030041:
sessions[session_nb - 1] = new eDVBCICAManagerSession(slot); sessions[session_nb - 1] = new eDVBCICAManagerSession(slot);
printf("CA MANAGER\n"); printf("[CI SESS] CA MANAGER\n");
break; break;
case 0x00240041: case 0x00240041:
sessions[session_nb - 1] = new eDVBCIDateTimeSession(slot); sessions[session_nb - 1] = new eDVBCIDateTimeSession(slot);
printf("DATE-TIME\n"); printf("[CI SESS] 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("[CI SESS] MMI - create session\n");
break; break;
if (cCA::GetInstance()->CheckCerts()) if (cCA::GetInstance()->CheckCerts())
{ {
case 0x008c1001: case 0x008c1001:
printf("CC MANAGER\n"); printf("[CI SESS] CC MANAGER\n");
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot); sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
break; break;
} }
case 0x00100041: case 0x00100041:
// session=new eDVBCIAuthSession; // session=new eDVBCIAuthSession;
printf("AuthSession\n"); printf("[CI SESS] AuthSession\n");
// break; // break;
case 0x00200041: case 0x00200041:
default: default:
printf("unknown resource type %02x %02x %02x %02x\n", resource_identifier[0], resource_identifier[1], resource_identifier[2], resource_identifier[3]); printf("[CI SESS] unknown resource type %02x %02x %02x %02x\n", resource_identifier[0], resource_identifier[1], resource_identifier[2], resource_identifier[3]);
sessions[session_nb - 1] = 0; sessions[session_nb - 1] = 0;
status = 0xF0; status = 0xF0;
} }
if (!sessions[session_nb - 1]) if (!sessions[session_nb - 1])
{ {
printf("unknown session.. expect crash\n"); printf("[CI SESS] unknown session.. expect crash\n");
return NULL; return NULL;
} }
printf("%s -> new session nb %d %p\n", FILENAME, session_nb, sessions[session_nb - 1]); printf("[CI SESS] new session nb %d %p\n", 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])
@@ -215,7 +211,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
void eDVBCISession::handleClose() void eDVBCISession::handleClose()
{ {
printf("%s %s\n", FILENAME, __FUNCTION__); printf("%s\n", __FUNCTION__);
unsigned char data[1] = {0x00}; unsigned char data[1] = {0x00};
sendSPDU(0x96, data, 1, 0, 0); sendSPDU(0x96, data, 1, 0, 0);
@@ -228,6 +224,7 @@ int eDVBCISession::pollAll()
if (sessions[session_nb - 1]) if (sessions[session_nb - 1])
{ {
int r; int r;
if (sessions[session_nb - 1]->state == stateInDeletion) if (sessions[session_nb - 1]->state == stateInDeletion)
{ {
sessions[session_nb - 1]->handleClose(); sessions[session_nb - 1]->handleClose();
@@ -246,22 +243,23 @@ int eDVBCISession::pollAll()
return 0; return 0;
} }
void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t len) void eDVBCISession::receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len)
{ {
printf("%s -> %s\n",FILENAME, __FUNCTION__);
#if 0
for(unsigned int i = 0; i < len; i++)
printf("%02x ", ptr[i]);
printf("\n");
#endif
if ((ptr[0] == 0x90 || ptr[0] == 0x95) && (ptr[3] == 0 )) if ((ptr[0] == 0x90 || ptr[0] == 0x95) && (ptr[3] == 0 ))
{ {
printf("****Mist: %02x %02x %02x %02x\n", ptr[0], ptr[1], ptr[2], ptr[3]); printf("[CI SESS] ****Mist: %02x %02x %02x %02x\n", ptr[0], ptr[1], ptr[2], ptr[3]);
} }
const unsigned char *pkt = (const unsigned char*)ptr; const unsigned char *pkt = (const unsigned char*)ptr;
unsigned char tag = *pkt++; unsigned char tag = *pkt++;
int llen, hlen; int llen, hlen;
printf("[CI SESS] slot: %p",slot);
#if 0
for(unsigned int i = 0; i < len; i++)
printf("%02x ", ptr[i]);
printf("\n");
#endif
llen = parseLengthField(pkt, hlen); llen = parseLengthField(pkt, hlen);
pkt += llen; pkt += llen;
@@ -290,14 +288,14 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
if ((!session_nb) || (session_nb >= SLMS)) if ((!session_nb) || (session_nb >= SLMS))
{ {
printf("PROTOCOL: illegal session number %x\n", session_nb); printf("[CI SESS] PROTOCOL: illegal session number %x\n", session_nb);
return; return;
} }
session = sessions[session_nb - 1]; session = sessions[session_nb - 1];
if (!session) if (!session)
{ {
printf("PROTOCOL: data on closed session %x\n", session_nb); printf("[CI SESS] PROTOCOL: data on closed session %x\n", session_nb);
return; return;
} }
@@ -309,10 +307,11 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
session->recvCreateSessionResponse(pkt); session->recvCreateSessionResponse(pkt);
break; break;
case 0x95: case 0x95:
printf("[CI SESS] recvCloseSessionRequest");
session->recvCloseSessionRequest(pkt); session->recvCloseSessionRequest(pkt);
break; break;
default: default:
printf("INTERNAL: nyi, tag %02x.\n", tag); printf("[CI SESS] INTERNAL: nyi, tag %02x.\n", tag);
return; return;
} }
} }
@@ -324,7 +323,6 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
if (session) if (session)
{ {
//printf("len %d\n", len);
while (len > 0) while (len > 0)
{ {
int alen; int alen;
@@ -339,7 +337,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
if (((len - alen) > 0) && ((len - alen) < 3)) if (((len - alen) > 0) && ((len - alen) < 3))
{ {
printf("WORKAROUND: applying work around MagicAPDULength\n"); printf("[CI SESS] WORKAROUND: applying work around MagicAPDULength\n");
alen = len; alen = len;
} }
@@ -352,7 +350,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
} }
} }
if (len) if (len)
printf("PROTOCOL: warning, TL-Data has invalid length\n"); printf("[CI SESS] PROTOCOL: warning, TL-Data has invalid length\n");
} }
eDVBCISession::~eDVBCISession() eDVBCISession::~eDVBCISession()

View File

@@ -12,16 +12,16 @@
class eDVBCISession class eDVBCISession
{ {
static eDVBCISession* sessions[SLMS]; static eDVBCISession* sessions[SLMS];
static eDVBCISession* createSession(tSlot *slot, const unsigned char *resource_identifier, unsigned char &status); static eDVBCISession* createSession(eDVBCISlot *slot, const unsigned char *resource_identifier, unsigned char &status);
static void sendSPDU(tSlot *slot, unsigned char tag,const void *data, int len, unsigned short session_nb, const void *apdu = 0, int alen = 0); static void sendSPDU(eDVBCISlot *slot, unsigned char tag,const void *data, int len, unsigned short session_nb, const void *apdu = 0, int alen = 0);
static void sendOpenSessionResponse(tSlot *slot,unsigned char session_status, const unsigned char *resource_identifier, unsigned short session_nb); static void sendOpenSessionResponse(eDVBCISlot *slot,unsigned char session_status, const unsigned char *resource_identifier, unsigned short session_nb);
void recvCreateSessionResponse(const unsigned char *data); void recvCreateSessionResponse(const unsigned char *data);
void recvCloseSessionRequest(const unsigned char *data); void recvCloseSessionRequest(const unsigned char *data);
protected: protected:
int state; int state;
int status; int status;
int action; int action;
tSlot *slot; eDVBCISlot *slot;
unsigned short session_nb; unsigned short session_nb;
virtual int receivedAPDU(const unsigned char *tag, const void *data, int len) = 0; virtual int receivedAPDU(const unsigned char *tag, const void *data, int len) = 0;
void sendAPDU(const unsigned char *tag, const void *data=0,int len=0); void sendAPDU(const unsigned char *tag, const void *data=0,int len=0);
@@ -30,7 +30,7 @@ protected:
public: public:
virtual ~eDVBCISession(); virtual ~eDVBCISession();
static void deleteSessions(const tSlot *slot); static void deleteSessions(const eDVBCISlot *slot);
void sendSPDU(unsigned char tag, const void *data, int len, const void *apdu = 0, int alen = 0); void sendSPDU(unsigned char tag, const void *data, int len, const void *apdu = 0, int alen = 0);
int poll() { if (action) { action=doAction(); return 1; } return 0; } int poll() { if (action) { action=doAction(); return 1; } return 0; }
@@ -39,7 +39,7 @@ public:
static int parseLengthField(const unsigned char *pkt, int &len); static int parseLengthField(const unsigned char *pkt, int &len);
static int buildLengthField(unsigned char *pkt, int len); static int buildLengthField(unsigned char *pkt, int len);
static void receiveData(tSlot *slot, const unsigned char *ptr, size_t len); static void receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len);
int getState() { return state; } int getState() { return state; }
int getStatus() { return status; } int getStatus() { return status; }