mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
test c**
Origin commit data
------------------
Branch: master
Commit: 0bbcfaf171
Author: max_10 <max_10@gmx.de>
Date: 2015-11-10 (Tue, 10 Nov 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
291
common/ca_ci.cpp
291
common/ca_ci.cpp
@@ -25,17 +25,20 @@
|
|||||||
#include <dvbci_appmgr.h>
|
#include <dvbci_appmgr.h>
|
||||||
#include <dvbci_camgr.h>
|
#include <dvbci_camgr.h>
|
||||||
#include <dvbci_mmi.h>
|
#include <dvbci_mmi.h>
|
||||||
|
#include <dvbci_ccmgr.h>
|
||||||
|
|
||||||
/* for some debug > set to 1 */
|
/* for some debug > set to 1 */
|
||||||
#define x_debug 1
|
#define x_debug 1
|
||||||
#define y_debug 0
|
#define y_debug 0
|
||||||
|
|
||||||
|
#define tricky 0
|
||||||
|
|
||||||
#define TAG_MENU_ANSWER 0x9f880b
|
#define TAG_MENU_ANSWER 0x9f880b
|
||||||
#define TAG_ENTER_MENU 0x9f8022
|
#define TAG_ENTER_MENU 0x9f8022
|
||||||
|
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_CA, this, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_CA, this, args)
|
||||||
|
|
||||||
static const char * FILENAME = "[ca.cpp]";
|
static const char * FILENAME = "[ca_ci]";
|
||||||
|
|
||||||
/* für callback */
|
/* für callback */
|
||||||
/* nur diese Message wird vom CI aus neutrinoMessages.h benutzt */
|
/* nur diese Message wird vom CI aus neutrinoMessages.h benutzt */
|
||||||
@@ -177,46 +180,8 @@ eData waitData(int fd, unsigned char* buffer, int* len)
|
|||||||
return eDataError;
|
return eDataError;
|
||||||
}
|
}
|
||||||
|
|
||||||
//send some data on an fd, for a special slot and connection_id
|
static bool transmitData(tSlot* slot, unsigned char* d, int len)
|
||||||
eData sendData(tSlot* slot, unsigned char* data, int len)
|
|
||||||
{
|
{
|
||||||
unsigned char *d = (unsigned char*) malloc(len + 5);
|
|
||||||
|
|
||||||
// only poll connection if we are not awaiting an answer
|
|
||||||
slot->pollConnection = false;
|
|
||||||
|
|
||||||
/* should we send a data last ? */
|
|
||||||
if (data != NULL)
|
|
||||||
{
|
|
||||||
if ((data[2] >= T_SB) && (data[2] <= T_NEW_T_C))
|
|
||||||
{
|
|
||||||
memcpy(d, data, len);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//send data_last and data
|
|
||||||
memcpy(d + 5, data, len);
|
|
||||||
d[0] = slot->slot;
|
|
||||||
d[1] = slot->connection_id;
|
|
||||||
d[2] = T_DATA_LAST;
|
|
||||||
if (len > 127)
|
|
||||||
d[3] = 4;
|
|
||||||
else
|
|
||||||
d[3] = len + 1;
|
|
||||||
d[4] = slot->connection_id;
|
|
||||||
len += 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//send a data last only
|
|
||||||
d[0] = slot->slot;
|
|
||||||
d[1] = slot->connection_id;
|
|
||||||
d[2] = T_DATA_LAST;
|
|
||||||
d[3] = len + 1;
|
|
||||||
d[4] = slot->connection_id;
|
|
||||||
len = 5;
|
|
||||||
}
|
|
||||||
#ifdef direct_write
|
#ifdef direct_write
|
||||||
int res = write(slot->fd, d, len);
|
int res = write(slot->fd, d, len);
|
||||||
|
|
||||||
@@ -227,21 +192,116 @@ eData sendData(tSlot* slot, unsigned char* data, int len)
|
|||||||
return eDataError;
|
return eDataError;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
#if x_debug
|
||||||
|
printf("SendData with data (len %d) >\n", len);
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
printf("%02x ", d[i]);
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
slot->sendqueue.push(queueData(d, len));
|
slot->sendqueue.push(queueData(d, len));
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool sendDataLast(tSlot* slot)
|
||||||
|
{
|
||||||
|
unsigned char data[5];
|
||||||
|
slot->pollConnection = false;
|
||||||
|
slot->DataLast = false;
|
||||||
|
data[0] = slot->slot;
|
||||||
|
data[1] = slot->connection_id;
|
||||||
|
data[2] = T_DATA_LAST;
|
||||||
|
data[3] = 1;
|
||||||
|
data[4] = slot->connection_id;
|
||||||
|
#if y_debug
|
||||||
|
printf("*** > Data Last: ");
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
printf("%02x ", data[i]);
|
||||||
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
write(slot->fd, data, 5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool sendRCV(tSlot* slot)
|
||||||
|
{
|
||||||
|
unsigned char send_data[5];
|
||||||
|
slot->pollConnection = false;
|
||||||
|
slot->DataRCV = false;
|
||||||
|
send_data[0] = slot->slot;
|
||||||
|
send_data[1] = slot->connection_id;
|
||||||
|
send_data[2] = T_RCV;
|
||||||
|
send_data[3] = 1;
|
||||||
|
send_data[4] = slot->connection_id;
|
||||||
|
printf("*** > T_RCV: ");
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
printf("%02x ", send_data[i]);
|
||||||
|
printf("\n");
|
||||||
|
write(slot->fd, send_data, 5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//send some data on an fd, for a special slot and connection_id
|
||||||
|
eData sendData(tSlot* slot, unsigned char* data, int len)
|
||||||
|
{
|
||||||
|
// only poll connection if we are not awaiting an answer
|
||||||
|
slot->pollConnection = false;
|
||||||
|
|
||||||
|
//send data_last and data
|
||||||
|
if (len < 127) {
|
||||||
|
unsigned char *d = (unsigned char*) malloc(len + 5);
|
||||||
|
memcpy(d + 5, data, len);
|
||||||
|
d[0] = slot->slot;
|
||||||
|
d[1] = slot->connection_id;
|
||||||
|
d[2] = T_DATA_LAST;
|
||||||
|
d[3] = len + 1;
|
||||||
|
d[4] = slot->connection_id;
|
||||||
|
len += 5;
|
||||||
|
transmitData(slot, d, len);
|
||||||
|
}
|
||||||
|
else if (len > 126 && len < 255) {
|
||||||
|
unsigned char *d = (unsigned char*) malloc(len + 6);
|
||||||
|
memcpy(d + 6, data, len);
|
||||||
|
d[0] = slot->slot;
|
||||||
|
d[1] = slot->connection_id;
|
||||||
|
d[2] = T_DATA_LAST;
|
||||||
|
d[3] = 0x81;
|
||||||
|
d[4] = len + 1;
|
||||||
|
d[5] = slot->connection_id;
|
||||||
|
len += 6;
|
||||||
|
transmitData(slot, d, len);
|
||||||
|
}
|
||||||
|
else if (len > 254) {
|
||||||
|
unsigned char *d = (unsigned char*) malloc(len + 7);
|
||||||
|
memcpy(d + 7, data, len);
|
||||||
|
d[0] = slot->slot;
|
||||||
|
d[1] = slot->connection_id;
|
||||||
|
d[2] = T_DATA_LAST;
|
||||||
|
d[3] = 0x82;
|
||||||
|
d[4] = len >> 8;
|
||||||
|
d[5] = len + 1;
|
||||||
|
d[6] = slot->connection_id;
|
||||||
|
len += 7;
|
||||||
|
transmitData(slot, d, len);
|
||||||
|
}
|
||||||
|
|
||||||
return eDataReady;
|
return eDataReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
//send a transport connection create request
|
//send a transport connection create request
|
||||||
bool sendCreateTC(tSlot* slot)
|
bool sendCreateTC(tSlot* slot)
|
||||||
{
|
{
|
||||||
unsigned char* data = (unsigned char*) malloc(sizeof(char) * 5);
|
unsigned char data[5];
|
||||||
data[0] = slot->slot;
|
data[0] = slot->slot;
|
||||||
data[1] = slot->slot + 1; /* conid */
|
data[1] = slot->slot + 1; /* conid */
|
||||||
data[2] = T_CREATE_T_C;
|
data[2] = T_CREATE_T_C;
|
||||||
data[3] = 1;
|
data[3] = 1;
|
||||||
data[4] = slot->slot + 1 /* conid */;
|
data[4] = slot->slot + 1 /* conid */;
|
||||||
sendData(slot, data, 5);
|
printf("Create TC: ");
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
printf("%02x ", data[i]);
|
||||||
|
printf("\n");
|
||||||
|
write(slot->fd, data, 5);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,9 +310,11 @@ void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_
|
|||||||
switch (tpdu_tag)
|
switch (tpdu_tag)
|
||||||
{
|
{
|
||||||
case T_C_T_C_REPLY:
|
case T_C_T_C_REPLY:
|
||||||
|
#if y_debug
|
||||||
printf("%s %s Got CTC Replay (slot %d, con %d)\n", FILENAME, __FUNCTION__, slot->slot, slot->connection_id);
|
printf("%s %s Got CTC Replay (slot %d, con %d)\n", FILENAME, __FUNCTION__, slot->slot, slot->connection_id);
|
||||||
//answer with data last (and if we have with data)
|
#endif
|
||||||
sendData(slot, NULL, 0);
|
/*answer with data last (and if we have with data)
|
||||||
|
--> DataLast flag will be generated in next loop from received APDU*/
|
||||||
break;
|
break;
|
||||||
case T_DELETE_T_C:
|
case T_DELETE_T_C:
|
||||||
//FIXME: close sessions etc; slot->reset ?
|
//FIXME: close sessions etc; slot->reset ?
|
||||||
@@ -282,16 +344,23 @@ void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_
|
|||||||
printf("%s -> single package\n", FILENAME);
|
printf("%s -> single package\n", FILENAME);
|
||||||
#if x_debug
|
#if x_debug
|
||||||
printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length);
|
printf("%s -> calling receiveData with data (len %d)\n", FILENAME, asn_data_length);
|
||||||
|
#if y_debug
|
||||||
for (int i = 0; i < asn_data_length; i++)
|
for (int i = 0; i < asn_data_length; i++)
|
||||||
printf("%02x ", data[i]);
|
printf("%02x ", data[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
eDVBCISession::receiveData(slot, data, asn_data_length);
|
#endif
|
||||||
eDVBCISession::pollAll();
|
/* to avoid illegal session number: only if > 0 */
|
||||||
|
if (asn_data_length)
|
||||||
|
{
|
||||||
|
eDVBCISession::receiveData(slot, data, asn_data_length);
|
||||||
|
eDVBCISession::pollAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* chained package */
|
/* chained package
|
||||||
|
?? DBO: I never have seen one */
|
||||||
int new_data_length = slot->receivedLen + asn_data_length;
|
int new_data_length = slot->receivedLen + asn_data_length;
|
||||||
printf("%s -> chained data\n", FILENAME);
|
printf("%s -> chained data\n", FILENAME);
|
||||||
__u8 *new_data_buffer = (__u8*) realloc(slot->receivedData, new_data_length);
|
__u8 *new_data_buffer = (__u8*) realloc(slot->receivedData, new_data_length);
|
||||||
@@ -318,22 +387,20 @@ void cCA::process_tpdu(tSlot* slot, unsigned char tpdu_tag, __u8* data, int asn_
|
|||||||
{
|
{
|
||||||
/* we now wait for an answer so dont poll */
|
/* we now wait for an answer so dont poll */
|
||||||
slot->pollConnection = false;
|
slot->pollConnection = false;
|
||||||
|
/* set the RCV Flag and set DataLast Flag false */
|
||||||
/* send the RCV and ask for the data */
|
slot->DataRCV = true;
|
||||||
unsigned char send_data[5];
|
slot->DataLast = false;
|
||||||
send_data[0] = slot->slot;
|
|
||||||
send_data[1] = slot->connection_id;
|
|
||||||
send_data[2] = T_RCV;
|
|
||||||
send_data[3] = 1;
|
|
||||||
send_data[4] = slot->connection_id;
|
|
||||||
write(slot->fd, send_data, 5);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//if the queue is not empty we dont need to send
|
/* set DataLast Flag if it is false*/
|
||||||
// a polling to the module.
|
if (!slot->DataLast)
|
||||||
//if (checkQueueSize(slot) == false)
|
{
|
||||||
// slot->pollConnection = true;
|
slot->DataLast = true;
|
||||||
|
#if y_debug
|
||||||
|
printf("**** > T_SB\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -490,14 +557,22 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
|
|||||||
{
|
{
|
||||||
(*it)->status = eStatusReset;
|
(*it)->status = eStatusReset;
|
||||||
usleep(200000);
|
usleep(200000);
|
||||||
|
if ((*it)->hasCCManager)
|
||||||
|
(*it)->ccmgrSession->ci_ccmgr_doClose((tSlot*)(*it));
|
||||||
eDVBCISession::deleteSessions((tSlot*)(*it));
|
eDVBCISession::deleteSessions((tSlot*)(*it));
|
||||||
(*it)->mmiSession = NULL;
|
(*it)->mmiSession = NULL;
|
||||||
(*it)->hasMMIManager = false;
|
(*it)->hasMMIManager = false;
|
||||||
(*it)->hasCAManager = false;
|
(*it)->hasCAManager = false;
|
||||||
|
(*it)->hasCCManager = false;
|
||||||
|
(*it)->ccmgr_ready = false;
|
||||||
(*it)->hasDateTime = false;
|
(*it)->hasDateTime = false;
|
||||||
(*it)->hasAppManager = false;
|
(*it)->hasAppManager = false;
|
||||||
(*it)->mmiOpened = false;
|
(*it)->mmiOpened = false;
|
||||||
(*it)->camIsReady = false;
|
(*it)->camIsReady = false;
|
||||||
|
|
||||||
|
(*it)->DataLast = false;
|
||||||
|
(*it)->DataRCV = false;
|
||||||
|
|
||||||
(*it)->counter = 0;
|
(*it)->counter = 0;
|
||||||
(*it)->init = false;
|
(*it)->init = false;
|
||||||
(*it)->pollConnection = false;
|
(*it)->pollConnection = false;
|
||||||
@@ -541,7 +616,7 @@ int cCA::GetCAIDS(CaIdVector &Caids)
|
|||||||
|
|
||||||
bool cCA::StopRecordCI( u64 tpid, u8 source, u32 calen)
|
bool cCA::StopRecordCI( u64 tpid, 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)
|
||||||
{
|
{
|
||||||
@@ -556,7 +631,7 @@ bool cCA::StopRecordCI( u64 tpid, u8 source, u32 calen)
|
|||||||
|
|
||||||
SlotIt cCA::FindFreeSlot(ca_map_t camap, unsigned char scrambled)
|
SlotIt cCA::FindFreeSlot(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;
|
||||||
ca_map_iterator_t caIt;
|
ca_map_iterator_t caIt;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -595,7 +670,7 @@ SlotIt cCA::FindFreeSlot(ca_map_t camap, unsigned char scrambled)
|
|||||||
/* 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*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled)
|
bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char * cabuf, u32 calen, const unsigned char * /*rawpmt*/, u32 /*rawlen*/, unsigned char scrambled, ca_map_t cm, int mode, bool enabled)
|
||||||
{
|
{
|
||||||
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("TPID: %llX\n", tpid);
|
||||||
@@ -684,6 +759,8 @@ cCA::cCA(int Slots)
|
|||||||
slot->camIsReady = false;
|
slot->camIsReady = false;
|
||||||
slot->hasMMIManager = false;
|
slot->hasMMIManager = false;
|
||||||
slot->hasCAManager = false;
|
slot->hasCAManager = false;
|
||||||
|
slot->hasCCManager = false;
|
||||||
|
slot->ccmgr_ready = false;
|
||||||
slot->hasDateTime = false;
|
slot->hasDateTime = false;
|
||||||
slot->hasAppManager = false;
|
slot->hasAppManager = false;
|
||||||
slot->mmiOpened = false;
|
slot->mmiOpened = false;
|
||||||
@@ -696,9 +773,15 @@ cCA::cCA(int Slots)
|
|||||||
slot->camask = 0;
|
slot->camask = 0;
|
||||||
memset(slot->pmtdata, 0, sizeof(slot->pmtdata));
|
memset(slot->pmtdata, 0, sizeof(slot->pmtdata));
|
||||||
|
|
||||||
|
slot->DataLast = false;
|
||||||
|
slot->DataRCV = false;
|
||||||
|
|
||||||
slot->counter = 0;
|
slot->counter = 0;
|
||||||
slot->init = false;
|
slot->init = false;
|
||||||
sprintf(slot->name, "unknown module %d", i);
|
sprintf(slot->name, "unknown module %d", i);
|
||||||
|
|
||||||
|
slot->private_data = NULL;
|
||||||
|
|
||||||
slot_data.push_back(slot);
|
slot_data.push_back(slot);
|
||||||
/* now reset the slot so the poll pri can happen in the thread */
|
/* now reset the slot so the poll pri can happen in the thread */
|
||||||
if (ioctl(fd, CA_RESET, i) < 0)
|
if (ioctl(fd, CA_RESET, i) < 0)
|
||||||
@@ -723,7 +806,7 @@ static cCA* pcCAInstance = NULL;
|
|||||||
|
|
||||||
cCA * cCA::GetInstance()
|
cCA * cCA::GetInstance()
|
||||||
{
|
{
|
||||||
printf("%s %s\n", FILENAME, __FUNCTION__);
|
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
||||||
|
|
||||||
if (pcCAInstance == NULL)
|
if (pcCAInstance == NULL)
|
||||||
{
|
{
|
||||||
@@ -768,12 +851,12 @@ void cCA::setSource(tSlot* slot)
|
|||||||
void cCA::slot_pollthread(void *c)
|
void cCA::slot_pollthread(void *c)
|
||||||
{
|
{
|
||||||
ca_slot_info_t info;
|
ca_slot_info_t info;
|
||||||
unsigned char data[1024];
|
unsigned char data[1024 * 4];
|
||||||
tSlot* slot = (tSlot*) c;
|
tSlot* slot = (tSlot*) c;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int len = 1024;
|
int len = 1024 *4;
|
||||||
unsigned char* d;
|
unsigned char* d;
|
||||||
eData status;
|
eData status;
|
||||||
|
|
||||||
@@ -852,6 +935,15 @@ void cCA::slot_pollthread(void *c)
|
|||||||
{
|
{
|
||||||
slot->pollConnection = false;
|
slot->pollConnection = false;
|
||||||
d = data;
|
d = data;
|
||||||
|
#if y_debug
|
||||||
|
if ((len == 6 && d[4] == 0x80) || len > 6) {
|
||||||
|
printf("slot: %d con-id: %d tpdu-tag: %02X len: %d\n", d[0], d[1], d[2], len);
|
||||||
|
printf("received data: >");
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
printf("%02x ", data[i]);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* taken from the dvb-apps */
|
/* taken from the dvb-apps */
|
||||||
int data_length = len - 2;
|
int data_length = len - 2;
|
||||||
d += 2; /* remove leading slot and connection id */
|
d += 2; /* remove leading slot and connection id */
|
||||||
@@ -872,10 +964,15 @@ void cCA::slot_pollthread(void *c)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
slot->connection_id = d[1 + length_field_len];
|
slot->connection_id = d[1 + length_field_len];
|
||||||
//printf("Setting connection_id from received data to %d\n", slot->connection_id);
|
#if y_debug
|
||||||
|
printf("Setting connection_id from received data to %d\n", slot->connection_id);
|
||||||
|
#endif
|
||||||
d += 1 + length_field_len + 1;
|
d += 1 + length_field_len + 1;
|
||||||
data_length -= (1 + length_field_len + 1);
|
data_length -= (1 + length_field_len + 1);
|
||||||
asn_data_length--;
|
asn_data_length--;
|
||||||
|
#if y_debug
|
||||||
|
printf("****tpdu_tag: 0x%02X\n", tpdu_tag);
|
||||||
|
#endif
|
||||||
process_tpdu(slot, tpdu_tag, d, asn_data_length, slot->connection_id);
|
process_tpdu(slot, tpdu_tag, d, asn_data_length, slot->connection_id);
|
||||||
// skip over the consumed data
|
// skip over the consumed data
|
||||||
d += asn_data_length;
|
d += asn_data_length;
|
||||||
@@ -884,6 +981,7 @@ void cCA::slot_pollthread(void *c)
|
|||||||
} /*if data ready */
|
} /*if data ready */
|
||||||
else if (status == eDataWrite)
|
else if (status == eDataWrite)
|
||||||
{
|
{
|
||||||
|
/* only writing any data here while status = eDataWrite */
|
||||||
if (!slot->sendqueue.empty())
|
if (!slot->sendqueue.empty())
|
||||||
{
|
{
|
||||||
const queueData &qe = slot->sendqueue.top();
|
const queueData &qe = slot->sendqueue.top();
|
||||||
@@ -898,15 +996,32 @@ void cCA::slot_pollthread(void *c)
|
|||||||
printf("r = %d, %m\n", res);
|
printf("r = %d, %m\n", res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
/* no comment :) */
|
||||||
|
#if tricky
|
||||||
|
if ((!checkQueueSize(slot) && !slot->hasCAManager && !slot->ccmgr_ready) || slot->counter < 3)
|
||||||
|
slot->pollConnection = true;
|
||||||
|
if (slot->hasCAManager && slot->ccmgr_ready)
|
||||||
|
slot->counter++;
|
||||||
|
#else
|
||||||
|
/* check for activate the pollConnection */
|
||||||
|
if (!checkQueueSize(slot) && (slot->DataRCV || slot->mmiOpened || slot->counter > 5))
|
||||||
{
|
{
|
||||||
//printf("sendqueue emtpy\n");
|
slot->pollConnection = true;
|
||||||
if ((checkQueueSize(slot) == false) && ((!slot->hasCAManager) || (slot->mmiOpened) || (slot->counter < 30)))
|
}
|
||||||
slot->pollConnection = true;
|
if (slot->counter < 6)
|
||||||
if (slot->hasCAManager && !slot->mmiOpened)
|
slot->counter++;
|
||||||
slot->counter++;
|
else
|
||||||
if (slot->mmiOpened)
|
slot->counter = 0;
|
||||||
slot->counter = 0;
|
#endif
|
||||||
|
/* if Flag: send a DataLast */
|
||||||
|
if (!checkQueueSize(slot) && slot->pollConnection && slot->DataLast)
|
||||||
|
{
|
||||||
|
sendDataLast(slot);
|
||||||
|
}
|
||||||
|
/* if Flag: send a RCV */
|
||||||
|
if (!checkQueueSize(slot) && slot->pollConnection && slot->DataRCV)
|
||||||
|
{
|
||||||
|
sendRCV(slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (status == eDataStatusChanged)
|
else if (status == eDataStatusChanged)
|
||||||
@@ -925,6 +1040,8 @@ void cCA::slot_pollthread(void *c)
|
|||||||
slot->mmiSession = NULL;
|
slot->mmiSession = NULL;
|
||||||
slot->hasMMIManager = false;
|
slot->hasMMIManager = false;
|
||||||
slot->hasCAManager = false;
|
slot->hasCAManager = false;
|
||||||
|
slot->hasCCManager = false;
|
||||||
|
slot->ccmgr_ready = false;
|
||||||
slot->hasDateTime = false;
|
slot->hasDateTime = false;
|
||||||
slot->hasAppManager = false;
|
slot->hasAppManager = false;
|
||||||
slot->mmiOpened = false;
|
slot->mmiOpened = false;
|
||||||
@@ -945,14 +1062,22 @@ void cCA::slot_pollthread(void *c)
|
|||||||
else if ((slot->camIsReady == true) && (!(info.flags & CA_CI_MODULE_READY)))
|
else if ((slot->camIsReady == true) && (!(info.flags & CA_CI_MODULE_READY)))
|
||||||
{
|
{
|
||||||
printf("cam (%d) status changed ->cam now _not_ present\n", slot->slot);
|
printf("cam (%d) status changed ->cam now _not_ present\n", slot->slot);
|
||||||
|
if (slot->hasCCManager)
|
||||||
|
slot->ccmgrSession->ci_ccmgr_doClose(slot);
|
||||||
eDVBCISession::deleteSessions(slot);
|
eDVBCISession::deleteSessions(slot);
|
||||||
slot->mmiSession = NULL;
|
slot->mmiSession = NULL;
|
||||||
slot->hasMMIManager = false;
|
slot->hasMMIManager = false;
|
||||||
slot->hasCAManager = false;
|
slot->hasCAManager = false;
|
||||||
|
slot->hasCCManager = false;
|
||||||
|
slot->ccmgr_ready = false;
|
||||||
slot->hasDateTime = false;
|
slot->hasDateTime = false;
|
||||||
slot->hasAppManager = false;
|
slot->hasAppManager = false;
|
||||||
slot->mmiOpened = false;
|
slot->mmiOpened = false;
|
||||||
slot->init = false;
|
slot->init = false;
|
||||||
|
|
||||||
|
slot->DataLast = false;
|
||||||
|
slot->DataRCV = false;
|
||||||
|
|
||||||
slot->counter = 0;
|
slot->counter = 0;
|
||||||
slot->pollConnection = false;
|
slot->pollConnection = false;
|
||||||
sprintf(slot->name, "unknown module %d", slot->slot);
|
sprintf(slot->name, "unknown module %d", slot->slot);
|
||||||
@@ -986,11 +1111,6 @@ void cCA::slot_pollthread(void *c)
|
|||||||
usleep(100000);
|
usleep(100000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!checkQueueSize(slot) && slot->pollConnection)
|
|
||||||
{
|
|
||||||
//printf("****poll1\n");
|
|
||||||
sendData(slot, NULL, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1024,10 +1144,14 @@ void cCA::slot_pollthread(void *c)
|
|||||||
SendMessage(pMsg);
|
SendMessage(pMsg);
|
||||||
/* resend a capmt if we have one. this is not very proper but I cant any mechanism in
|
/* resend a capmt if we have one. this is not very proper but I cant any mechanism in
|
||||||
neutrino currently. so if a cam is inserted a pmt is not resend */
|
neutrino currently. so if a cam is inserted a pmt is not resend */
|
||||||
|
/* not necessary: the arrived capmt will be automaticly send */
|
||||||
SendCaPMT(slot);
|
//SendCaPMT(slot);
|
||||||
}
|
}
|
||||||
if (slot->hasCAManager && slot->hasAppManager && slot->newCapmt)
|
if (slot->hasCAManager && slot->hasAppManager && slot->newCapmt
|
||||||
|
#if tricky
|
||||||
|
&& slot->ccmgr_ready
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
SendCaPMT(slot);
|
SendCaPMT(slot);
|
||||||
slot->newCapmt = false;
|
slot->newCapmt = false;
|
||||||
@@ -1059,7 +1183,6 @@ bool cCA::SendCaPMT(tSlot* slot)
|
|||||||
if (slot->fd > 0)
|
if (slot->fd > 0)
|
||||||
{
|
{
|
||||||
setSource(slot);
|
setSource(slot);
|
||||||
slot->counter = 0;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -156,6 +156,7 @@ struct queueData
|
|||||||
class eDVBCIMMISession;
|
class eDVBCIMMISession;
|
||||||
class eDVBCIApplicationManagerSession;
|
class eDVBCIApplicationManagerSession;
|
||||||
class eDVBCICAManagerSession;
|
class eDVBCICAManagerSession;
|
||||||
|
class eDVBCIContentControlManagerSession;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -176,14 +177,18 @@ typedef struct
|
|||||||
eDVBCIMMISession* mmiSession;
|
eDVBCIMMISession* mmiSession;
|
||||||
eDVBCIApplicationManagerSession* appSession;
|
eDVBCIApplicationManagerSession* appSession;
|
||||||
eDVBCICAManagerSession* camgrSession;
|
eDVBCICAManagerSession* camgrSession;
|
||||||
|
eDVBCIContentControlManagerSession* ccmgrSession;
|
||||||
|
|
||||||
bool hasAppManager;
|
bool hasAppManager;
|
||||||
bool hasMMIManager;
|
bool hasMMIManager;
|
||||||
bool hasCAManager;
|
bool hasCAManager;
|
||||||
|
bool hasCCManager;
|
||||||
bool hasDateTime;
|
bool hasDateTime;
|
||||||
bool mmiOpened;
|
bool mmiOpened;
|
||||||
bool init;
|
bool init;
|
||||||
|
|
||||||
|
bool ccmgr_ready;
|
||||||
|
|
||||||
char name[512];
|
char name[512];
|
||||||
|
|
||||||
bool newCapmt;
|
bool newCapmt;
|
||||||
@@ -192,11 +197,17 @@ typedef struct
|
|||||||
u32 pmtlen;
|
u32 pmtlen;
|
||||||
u8 source;
|
u8 source;
|
||||||
u8 camask;
|
u8 camask;
|
||||||
unsigned char pmtdata[1024];
|
unsigned char pmtdata[1024 * 4];
|
||||||
|
|
||||||
int counter;
|
int counter;
|
||||||
CaIdVector cam_caids;
|
CaIdVector cam_caids;
|
||||||
std::priority_queue<queueData> sendqueue;
|
std::priority_queue<queueData> sendqueue;
|
||||||
|
|
||||||
|
bool DataLast;
|
||||||
|
bool DataRCV;
|
||||||
|
/* private data */
|
||||||
|
void *private_data;
|
||||||
|
|
||||||
} tSlot;
|
} tSlot;
|
||||||
|
|
||||||
eData sendData(tSlot *slot, unsigned char* data, int len);
|
eData sendData(tSlot *slot, unsigned char* data, int len);
|
||||||
|
@@ -5,12 +5,17 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_srcdir)/include
|
-I$(top_srcdir)/include
|
||||||
|
|
||||||
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
|
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
|
||||||
AM_LDFLAGS = -lpthread
|
AM_LDFLAGS = -lpthread -lcrypto -lssl
|
||||||
|
|
||||||
libdvbci_la_SOURCES = \
|
libdvbci_la_SOURCES = \
|
||||||
dvbci_session.cpp \
|
dvbci_session.cpp \
|
||||||
dvbci_mmi.cpp \
|
dvbci_mmi.cpp \
|
||||||
dvbci_camgr.cpp \
|
dvbci_camgr.cpp \
|
||||||
|
misc.cpp \
|
||||||
|
descrambler.cpp \
|
||||||
|
dh_rsa_misc.cpp \
|
||||||
|
aes_xcbc_mac.cpp \
|
||||||
|
dvbci_ccmgr.cpp \
|
||||||
dvbci_appmgr.cpp \
|
dvbci_appmgr.cpp \
|
||||||
dvbci_datetimemgr.cpp \
|
dvbci_datetimemgr.cpp \
|
||||||
dvbci_resmgr.cpp
|
dvbci_resmgr.cpp
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
/* DVB CI DateTime Manager */
|
/* DVB CI DateTime Manager */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "dvbci_datetimemgr.h"
|
#include "dvbci_datetimemgr.h"
|
||||||
|
|
||||||
|
static const char * FILENAME = "[dvbci_datetimemgr]";
|
||||||
|
|
||||||
eDVBCIDateTimeSession::eDVBCIDateTimeSession(tSlot *tslot)
|
eDVBCIDateTimeSession::eDVBCIDateTimeSession(tSlot *tslot)
|
||||||
{
|
{
|
||||||
slot = tslot;
|
slot = tslot;
|
||||||
@@ -46,8 +51,30 @@ int eDVBCIDateTimeSession::doAction()
|
|||||||
return 0;
|
return 0;
|
||||||
case stateSendDateTime:
|
case stateSendDateTime:
|
||||||
{
|
{
|
||||||
|
struct tm tm_gmt;
|
||||||
|
struct tm tm_loc;
|
||||||
unsigned char tag[3] = {0x9f, 0x84, 0x41}; // date_time_response
|
unsigned char tag[3] = {0x9f, 0x84, 0x41}; // date_time_response
|
||||||
unsigned char msg[7] = {0, 0, 0, 0, 0, 0, 0};
|
unsigned char msg[7] = {0, 0, 0, 0, 0, 0, 0};
|
||||||
|
printf("%s -> %s\n", FILENAME, __FUNCTION__);
|
||||||
|
time_t t = time(NULL);
|
||||||
|
if ( gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc) )
|
||||||
|
{
|
||||||
|
int Y = tm_gmt.tm_year;
|
||||||
|
int M = tm_gmt.tm_mon + 1;
|
||||||
|
int D = tm_gmt.tm_mday;
|
||||||
|
int L = (M == 1 || M == 2) ? 1 : 0;
|
||||||
|
int MJD = 14956 + D + (int)((Y - L) * 365.25) + (int)((M + 1 + L * 12) * 30.6001);
|
||||||
|
|
||||||
|
#define DEC2BCD(d) (((d / 10) << 4) + (d % 10))
|
||||||
|
|
||||||
|
msg[0] = htons(MJD) >> 8;
|
||||||
|
msg[1] = htons(MJD) & 0xff;
|
||||||
|
msg[2] = DEC2BCD(tm_gmt.tm_hour);
|
||||||
|
msg[3] = DEC2BCD(tm_gmt.tm_min);
|
||||||
|
msg[4] = DEC2BCD(tm_gmt.tm_sec);
|
||||||
|
msg[5] = htons(tm_loc.tm_gmtoff / 60) >> 8;
|
||||||
|
msg[6] = htons(tm_loc.tm_gmtoff / 60) & 0xff;
|
||||||
|
}
|
||||||
sendAPDU(tag, msg, 7);
|
sendAPDU(tag, msg, 7);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ static const char * FILENAME = "[dvbci_mmi]";
|
|||||||
|
|
||||||
eDVBCIMMISession::eDVBCIMMISession(tSlot *tslot)
|
eDVBCIMMISession::eDVBCIMMISession(tSlot *tslot)
|
||||||
{
|
{
|
||||||
printf("%s:%s\n", FILENAME, __func__);
|
printf("%s -> %s\n", FILENAME, __func__);
|
||||||
slot = tslot;
|
slot = tslot;
|
||||||
slot->hasMMIManager = true;
|
slot->hasMMIManager = true;
|
||||||
slot->mmiSession = this;
|
slot->mmiSession = this;
|
||||||
|
@@ -6,7 +6,7 @@ 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) %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++)
|
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");
|
||||||
@@ -15,7 +15,7 @@ int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const v
|
|||||||
switch (tag[2])
|
switch (tag[2])
|
||||||
{
|
{
|
||||||
case 0x10: // profile enquiry
|
case 0x10: // profile enquiry
|
||||||
printf("cam fragt was ich kann.");
|
printf("cam fragt was ich kann.\n");
|
||||||
state = stateProfileEnquiry;
|
state = stateProfileEnquiry;
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
@@ -72,10 +72,12 @@ int eDVBCIResourceManagerSession::doAction()
|
|||||||
{
|
{
|
||||||
{0x00, 0x01, 0x00, 0x41},
|
{0x00, 0x01, 0x00, 0x41},
|
||||||
{0x00, 0x02, 0x00, 0x41},
|
{0x00, 0x02, 0x00, 0x41},
|
||||||
|
{0x00, 0x02, 0x00, 0x43},
|
||||||
{0x00, 0x03, 0x00, 0x41},
|
{0x00, 0x03, 0x00, 0x41},
|
||||||
// {0x00, 0x20, 0x00, 0x41}, // host control
|
// {0x00, 0x20, 0x00, 0x41}, // host control
|
||||||
{0x00, 0x40, 0x00, 0x41},
|
{0x00, 0x40, 0x00, 0x41},
|
||||||
{0x00, 0x24, 0x00, 0x41}
|
{0x00, 0x24, 0x00, 0x41},
|
||||||
|
{0x00, 0x8c, 0x10, 0x01} // content control
|
||||||
// {0x00, 0x10, 0x00, 0x41} // auth.
|
// {0x00, 0x10, 0x00, 0x41} // auth.
|
||||||
};
|
};
|
||||||
sendAPDU(tag, data, sizeof(data));
|
sendAPDU(tag, data, sizeof(data));
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include "dvbci_camgr.h"
|
#include "dvbci_camgr.h"
|
||||||
#include "dvbci_datetimemgr.h"
|
#include "dvbci_datetimemgr.h"
|
||||||
#include "dvbci_mmi.h"
|
#include "dvbci_mmi.h"
|
||||||
|
#include "dvbci_ccmgr.h"
|
||||||
|
|
||||||
static const char * FILENAME = "[dvbci_session]";
|
static const char * FILENAME = "[dvbci_session]";
|
||||||
|
|
||||||
@@ -156,6 +157,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
|
|||||||
printf("RESOURCE MANAGER\n");
|
printf("RESOURCE MANAGER\n");
|
||||||
break;
|
break;
|
||||||
case 0x00020041:
|
case 0x00020041:
|
||||||
|
case 0x00020043:
|
||||||
sessions[session_nb - 1] = new eDVBCIApplicationManagerSession(slot);
|
sessions[session_nb - 1] = new eDVBCIApplicationManagerSession(slot);
|
||||||
printf("APPLICATION MANAGER\n");
|
printf("APPLICATION MANAGER\n");
|
||||||
break;
|
break;
|
||||||
@@ -171,6 +173,10 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
|
|||||||
sessions[session_nb - 1] = new eDVBCIMMISession(slot);
|
sessions[session_nb - 1] = new eDVBCIMMISession(slot);
|
||||||
printf("MMI - create session\n");
|
printf("MMI - create session\n");
|
||||||
break;
|
break;
|
||||||
|
case 0x008c1001:
|
||||||
|
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
|
||||||
|
printf("CC MANAGER\n");
|
||||||
|
break;
|
||||||
case 0x00100041:
|
case 0x00100041:
|
||||||
// session=new eDVBCIAuthSession;
|
// session=new eDVBCIAuthSession;
|
||||||
printf("AuthSession\n");
|
printf("AuthSession\n");
|
||||||
@@ -236,12 +242,12 @@ int eDVBCISession::pollAll()
|
|||||||
|
|
||||||
void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t len)
|
void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t len)
|
||||||
{
|
{
|
||||||
printf("slot: %p\n", slot);
|
printf("%s -> %s\n",FILENAME, __FUNCTION__);
|
||||||
|
#if 0
|
||||||
for(unsigned int i = 0; i < len; i++)
|
for(unsigned int i = 0; i < len; i++)
|
||||||
printf("%02x ", ptr[i]);
|
printf("%02x ", ptr[i]);
|
||||||
printf("\n");
|
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("****Mist: %02x %02x %02x %02x\n", ptr[0], ptr[1], ptr[2], ptr[3]);
|
||||||
@@ -272,7 +278,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned session_nb;
|
unsigned session_nb;
|
||||||
printf("hlen = %d, %d, %d\n", hlen, pkt[hlen - 2], pkt[hlen - 1]);
|
//printf("hlen = %d, %d, %d\n", hlen, pkt[hlen - 2], pkt[hlen - 1]);
|
||||||
session_nb = pkt[hlen - 2] << 8;
|
session_nb = pkt[hlen - 2] << 8;
|
||||||
session_nb |= pkt[hlen - 1] & 0xFF;
|
session_nb |= pkt[hlen - 1] & 0xFF;
|
||||||
|
|
||||||
@@ -312,7 +318,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
|
|||||||
|
|
||||||
if (session)
|
if (session)
|
||||||
{
|
{
|
||||||
printf("len %d\n", len);
|
//printf("len %d\n", len);
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
int alen;
|
int alen;
|
||||||
@@ -323,7 +329,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
|
|||||||
pkt += hlen;
|
pkt += hlen;
|
||||||
len -= hlen;
|
len -= hlen;
|
||||||
|
|
||||||
printf("len = %d, hlen = %d, alen = %d\n", len, hlen, alen);
|
//printf("len = %d, hlen = %d, alen = %d\n", len, hlen, alen);
|
||||||
|
|
||||||
if (((len - alen) > 0) && ((len - alen) < 3))
|
if (((len - alen) > 0) && ((len - alen) < 3))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user