This commit is contained in:
max10
2015-11-15 20:29:20 +01:00
parent 43ded09d01
commit ca27972f16
5 changed files with 79 additions and 4 deletions

View File

@@ -570,6 +570,7 @@ void cCA::ModuleReset(enum CA_SLOT_TYPE, uint32_t slot)
(*it)->DataLast = false;
(*it)->DataRCV = false;
(*it)->SidBlackListed = false;
(*it)->counter = 0;
(*it)->init = false;
@@ -669,10 +670,13 @@ SlotIt cCA::FindFreeSlot(ca_map_t camap, unsigned char scrambled)
/* 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)
{
u16 SID = (u16)(tpid & 0x000000000000FFFF);
unsigned int i = 0;
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("SID: %04X\n", SID);
printf("SOURCE_DEMUX: %X\n", source_demux);
printf("CA_MASK: %X\n", camask);
printf("CALEN: %d\n", calen);
@@ -700,11 +704,17 @@ bool cCA::SendCAPMT(u64 tpid, u8 source_demux, u8 camask, const unsigned char *
(*It)->tpid = tpid;
(*It)->source = source_demux;
(*It)->pmtlen = calen;
for (unsigned int i = 0; i < calen; i++)
for (i = 0; i < calen; i++)
(*It)->pmtdata[i] = cabuf[i];
(*It)->newCapmt = true;
}
if (mode && scrambled && enabled)
if ((*It)->bsids.size())
{
for (i = 0; i < (*It)->bsids.size(); i++)
if ((*It)->bsids[i] == SID) {(*It)->SidBlackListed = true; break;}
if (i == (*It)->bsids.size()) {(*It)->SidBlackListed = false;}
}
if (mode && scrambled && enabled && !(*It)->SidBlackListed)
(*It)->inUse = true;
}
}
@@ -774,6 +784,7 @@ cCA::cCA(int Slots)
slot->DataLast = false;
slot->DataRCV = false;
slot->SidBlackListed = false;
slot->counter = 0;
slot->init = false;
@@ -1068,6 +1079,7 @@ void cCA::slot_pollthread(void *c)
slot->DataLast = false;
slot->DataRCV = false;
slot->SidBlackListed = false;
slot->counter = 0;
slot->pollConnection = false;
@@ -1138,7 +1150,7 @@ void cCA::slot_pollthread(void *c)
/* not necessary: the arrived capmt will be automaticly send */
//SendCaPMT(slot);
}
if (slot->hasCAManager && slot->hasAppManager && slot->newCapmt)
if (slot->hasCAManager && slot->hasAppManager && slot->newCapmt && !slot->SidBlackListed)
{
SendCaPMT(slot);
slot->newCapmt = false;

View File

@@ -103,6 +103,8 @@ typedef struct CA_MESSAGE {
typedef std::set<int> ca_map_t;
typedef ca_map_t::iterator ca_map_iterator_t;
typedef std::vector<u16> bSIDVector;
typedef std::vector<u16> CaIdVector;
typedef std::vector<u16>::iterator CaIdVectorIterator;
typedef std::vector<u16>::const_iterator CaIdVectorConstIterator;
@@ -203,11 +205,13 @@ typedef struct
CaIdVector cam_caids;
std::priority_queue<queueData> sendqueue;
bSIDVector bsids;
unsigned char lastKey[32];
unsigned char scrambled;
u8 lastParity;
bool DataLast;
bool DataRCV;
bool SidBlackListed;
/* private data */
void *private_data;

View File

@@ -1,6 +1,8 @@
/* DVB CI Application Manager */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "dvbci_appmgr.h"
@@ -73,6 +75,7 @@ int eDVBCIApplicationManagerSession::doAction()
const unsigned char tag[3] = {0x9F, 0x80, 0x20};
sendAPDU(tag);
state = stateFinal;
checkBlist();
return 1;
}
case stateFinal:
@@ -102,3 +105,56 @@ int eDVBCIApplicationManagerSession::startMMI()
return 0;
}
bool eDVBCIApplicationManagerSession::readBlist()
{
int rc, i;
char cSid[4] = {0,0,0,0};
u16 Sid;
FILE *fd;
char blacklist_file[32];
sprintf(blacklist_file,"/etc/blacklist_slot_%d",slot->slot);
if (access(blacklist_file, F_OK) != 0)
return false;
fd = fopen(blacklist_file,"r");
if (!fd)
return false;
else
{
do
{
for (i = 0; i < 4; i++)
{
rc = fgetc(fd);
if (rc == ',' || rc == EOF) break;
cSid[i] = (char)rc;
}
if (rc == EOF) goto fin;
if (i == 4)
{
Sid = (u16)strtol(cSid, NULL, 16);
slot->bsids.push_back(Sid);
}
} while (rc != EOF);
fin:
fclose(fd);
}
if (slot->bsids.size())
return true;
else
return false;
}
int eDVBCIApplicationManagerSession::checkBlist()
{
if (readBlist())
{
printf("Blacked sids: %d > ", slot->bsids.size());
for (unsigned int i = 0; i < slot->bsids.size(); i++)
printf("%04x ", slot->bsids[i]);
printf("\n");
}
return 0;
}

View File

@@ -14,6 +14,8 @@ class eDVBCIApplicationManagerSession: public eDVBCISession
int wantmenu;
int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction();
bool readBlist();
int checkBlist();
public:
eDVBCIApplicationManagerSession(tSlot *tslot);
~eDVBCIApplicationManagerSession();

View File

@@ -1327,6 +1327,7 @@ int eDVBCIContentControlManagerSession::doAction()
void eDVBCIContentControlManagerSession::resendKey(tSlot *tslot)
{
if (!tslot->SidBlackListed)
descrambler_set_key((int)tslot->source, tslot->lastParity, tslot->lastKey);
}