Skip to content

Commit

Permalink
Revert "add ciplushelper interface"
Browse files Browse the repository at this point in the history
This reverts commit 90a938d.

Support for this interface has been withdrawn.
  • Loading branch information
eriksl authored and Huevos committed Nov 3, 2017
1 parent f89f74f commit 1cee086
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 269 deletions.
113 changes: 0 additions & 113 deletions lib/dvb_ci/dvbci.cpp
Expand Up @@ -35,125 +35,12 @@

eDVBCIInterfaces *eDVBCIInterfaces::instance = 0;


eCIClient::eCIClient(eDVBCIInterfaces *handler, int socket) : eUnixDomainSocket(socket, 1, eApp), parent(handler)
{
receivedData = NULL;
receivedCmd = 0;
CONNECT(connectionClosed_, eCIClient::connectionLost);
CONNECT(readyRead_, eCIClient::dataAvailable);
}

void eCIClient::connectionLost()
{
if (parent) parent->connectionLost();
}

void eCIClient::dataAvailable()
{
if (!receivedCmd)
{
if ((unsigned int)bytesAvailable() < sizeof(ciplus_header)) return;
if ((unsigned int)readBlock((char*)&header, sizeof(ciplus_header)) < sizeof(ciplus_header)) return;
header.magic = ntohl(header.magic);
header.cmd = ntohl(header.cmd);
header.size = ntohl(header.size);
if (header.magic != CIPLUSHELPER_MAGIC)
{
if (parent) parent->connectionLost();
return;
}
receivedCmd = header.cmd;
receivedCmdSize = header.size;
}
if (receivedCmdSize)
{
if ((unsigned int)bytesAvailable() < receivedCmdSize) return;
if (receivedCmdSize) delete [] receivedData;
receivedData = new unsigned char[receivedCmdSize];
if ((unsigned int)readBlock((char*)receivedData, receivedCmdSize) < receivedCmdSize) return;

ciplus_message *message = (ciplus_message *)receivedData;
switch (header.cmd)
{
default:
{
unsigned char *data = &receivedData[sizeof(ciplus_message)];
parent->getSlot(ntohl(message->slot))->send(data, ntohl(message->size));
}
break;
case eCIClient::CIPLUSHELPER_STATE_CHANGED:
{
eDVBCISession::setAction(ntohl(message->session), receivedData[sizeof(ciplus_message)]);
}
break;
}
receivedCmdSize = 0;
receivedCmd = 0;
}
}

void eCIClient::sendData(int cmd, int slot, int session, unsigned long idtag, unsigned char *tag, unsigned char *data, int len)
{
ciplus_message message;
message.slot = ntohl(slot);
message.idtag = ntohl(idtag);
memcpy(&message.tag, tag, 4);
message.session = ntohl(session);
message.size = ntohl(len);

ciplus_header header;
header.magic = htonl(CIPLUSHELPER_MAGIC);
header.size = htonl(sizeof(message) + len);
header.cmd = htonl(cmd);

writeBlock((const char*)&header, sizeof(header));
writeBlock((const char*)&message, sizeof(message));
if (len)
{
writeBlock((const char*)data, len);
}
}

void eDVBCIInterfaces::newConnection(int socket)
{
if (client)
{
delete client;
}
client = new eCIClient(this, socket);
}

void eDVBCIInterfaces::connectionLost()
{
if (client)
{
delete client;
client = NULL;
}
}

void eDVBCIInterfaces::sendDataToHelper(int cmd, int slot, int session, unsigned long idtag, unsigned char *tag, unsigned char *data, int len)
{
if (client) client->sendData(cmd, slot, session, idtag, tag, data, len);
}

bool eDVBCIInterfaces::isClientConnected()
{
if (client) return true;
return false;
}

#define CIPLUS_SERVER_SOCKET "/tmp/.listen.ciplus.socket"

eDVBCIInterfaces::eDVBCIInterfaces()
: eServerSocket(CIPLUS_SERVER_SOCKET, eApp)
{
int num_ci = 0;
std::stringstream path;

instance = this;
client = NULL;

eDebug("[CI] scanning for common interfaces..");

Expand Down
64 changes: 2 additions & 62 deletions lib/dvb_ci/dvbci.h
Expand Up @@ -9,8 +9,6 @@
#include <set>
#include <queue>

#include <lib/network/serversocket.h>

class eDVBCISession;
class eDVBCIApplicationManagerSession;
class eDVBCICAManagerSession;
Expand Down Expand Up @@ -115,70 +113,19 @@ typedef std::list<CIPmtHandler> PMTHandlerList;

#endif // SWIG

#ifndef SWIG
class eCIClient : public eUnixDomainSocket
{
struct ciplus_header
{
unsigned int magic;
unsigned int cmd;
unsigned int size;
}__attribute__((packed));

struct ciplus_message
{
unsigned int slot;
unsigned long idtag;
unsigned char tag[4];
unsigned int session;
unsigned int size;
}__attribute__((packed));

unsigned int receivedLength;
unsigned int receivedCmd;
unsigned int receivedCmdSize;
unsigned char *receivedData;

ciplus_header header;
protected:
eDVBCIInterfaces *parent;
void connectionLost();
void dataAvailable();
public:
eCIClient(eDVBCIInterfaces *handler, int socket);
void sendData(int cmd, int slot, int session, unsigned long idtag, unsigned char *tag, unsigned char *data, int len);

enum
{
CIPLUSHELPER_SESSION_CREATE = 1000,
CIPLUSHELPER_SESSION_CLOSE = 1001,
CIPLUSHELPER_RECV_APDU = 1002,
CIPLUSHELPER_DOACTION = 1003,
CIPLUSHELPER_STATE_CHANGED = 1004,
CIPLUSHELPER_DATA = 1005,
CIPLUSHELPER_MAGIC = 987654321,
};
};

class eDVBCIInterfaces: public eServerSocket
#else
class eDVBCIInterfaces
#endif
{
DECLARE_REF(eDVBCIInterfaces);
static eDVBCIInterfaces *instance;
eSmartPtrList<eDVBCISlot> m_slots;
PMTHandlerList m_pmt_handlers;

eCIClient *client;
eDVBCISlot *getSlot(int slotid);
PMTHandlerList m_pmt_handlers;
#ifndef SWIG
public:
#endif
eDVBCIInterfaces();
~eDVBCIInterfaces();

eDVBCISlot *getSlot(int slotid);

void addPMTHandler(eDVBServicePMTHandler *pmthandler);
void removePMTHandler(eDVBServicePMTHandler *pmthandler);
void recheckPMTHandlers();
Expand All @@ -197,10 +144,6 @@ class eDVBCIInterfaces
int sendCAPMT(int slot);
int setInputSource(int tunerno, const std::string &source);
int setCIClockRate(int slot, int rate);

void newConnection(int socket);
void connectionLost();

#ifdef SWIG
public:
#endif
Expand All @@ -209,9 +152,6 @@ class eDVBCIInterfaces
PyObject *getDescrambleRules(int slotid);
RESULT setDescrambleRules(int slotid, SWIG_PYOBJECT(ePyObject) );
PyObject *readCICaIds(int slotid);

void sendDataToHelper(int cmd, int slot, int session, unsigned long idtag, unsigned char *tag, unsigned char *data, int len);
bool isClientConnected();
};

#endif
28 changes: 2 additions & 26 deletions lib/dvb_ci/dvbci_resmgr.cpp
Expand Up @@ -68,10 +68,7 @@ int eDVBCIResourceManagerSession::doAction()
case stateProfileEnquiry:
{
const unsigned char tag[3]={0x9F, 0x80, 0x11};

if (!eDVBCIInterfaces::getInstance()->isClientConnected())
{
const unsigned char data[][4]=
const unsigned char data[][4]=
{
{0x00, 0x01, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x41},
Expand All @@ -81,28 +78,7 @@ int eDVBCIResourceManagerSession::doAction()
{0x00, 0x40, 0x00, 0x41},
// {0x00, 0x10, 0x00, 0x41}, // auth.
};
sendAPDU(tag, data, sizeof(data));
}
else
{
const unsigned char data[][4]=
{
{0x00, 0x01, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x42},
{0x00, 0x03, 0x00, 0x41},
{0x00, 0x20, 0x00, 0x41},
{0x00, 0x24, 0x00, 0x41},
{0x00, 0x40, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x43},
{0x00, 0x8C, 0x10, 0x01},
{0x00, 0x8D, 0x10, 0x01},
{0x00, 0x8E, 0x10, 0x01},
{0x00, 0x97, 0x10, 0x01},
{0x00, 0x41, 0x00, 0x41},
};
sendAPDU(tag, data, sizeof(data));
}
sendAPDU(tag, data, sizeof(data));
state=stateFinal;
return 0;
}
Expand Down
58 changes: 4 additions & 54 deletions lib/dvb_ci/dvbci_session.cpp
Expand Up @@ -7,33 +7,6 @@
#include <lib/dvb_ci/dvbci_camgr.h>
#include <lib/dvb_ci/dvbci_datetimemgr.h>
#include <lib/dvb_ci/dvbci_mmi.h>
#include <lib/dvb_ci/dvbci.h>
#include <lib/dvb_ci/dvbci_ui.h>

eDVBCIPlusHelper::eDVBCIPlusHelper(eDVBCISlot *tslot, unsigned long tag, int session)
{
m_tslot = tslot;
m_tag = tag;
m_session = session;
eDVBCIInterfaces::getInstance()->sendDataToHelper(eCIClient::CIPLUSHELPER_SESSION_CREATE, m_tslot->getSlotID(), m_session, m_tag, (unsigned char *)"\x00\x00\x00\x00", NULL, 0);
}

eDVBCIPlusHelper::~eDVBCIPlusHelper()
{
eDVBCIInterfaces::getInstance()->sendDataToHelper(eCIClient::CIPLUSHELPER_SESSION_CLOSE, m_tslot->getSlotID(), m_session, m_tag, (unsigned char *)"\x00\x00\x00\x00", NULL, 0);
}

int eDVBCIPlusHelper::receivedAPDU(const unsigned char *tag, const void *data, int len)
{
eDVBCIInterfaces::getInstance()->sendDataToHelper(eCIClient::CIPLUSHELPER_RECV_APDU, m_tslot->getSlotID(), m_session, m_tag, (unsigned char *)tag, (unsigned char *)data, len);
return 0;
}

int eDVBCIPlusHelper::doAction()
{
eDVBCIInterfaces::getInstance()->sendDataToHelper(eCIClient::CIPLUSHELPER_DOACTION, m_tslot->getSlotID(), m_session, m_tag, (unsigned char *)"\x00\x00\x00\x00", NULL, 0);
return 0;
}

DEFINE_REF(eDVBCISession);

Expand Down Expand Up @@ -175,14 +148,17 @@ void eDVBCISession::createSession(eDVBCISlot *slot, const unsigned char *resourc
eDebug("[CI SESS] RESOURCE MANAGER");
break;
case 0x00020041:
case 0x00020043:
session=new eDVBCIApplicationManagerSession(slot);
eDebug("[CI SESS] APPLICATION MANAGER");
break;
case 0x00030041:
session = new eDVBCICAManagerSession(slot);
eDebug("[CI SESS] CA MANAGER");
break;
case 0x00240041:
session=new eDVBCIDateTimeSession;
eDebug("[CI SESS] DATE-TIME");
break;
case 0x00400041:
session = new eDVBCIMMISession(slot);
eDebug("[CI SESS] MMI - create session");
Expand All @@ -191,22 +167,7 @@ void eDVBCISession::createSession(eDVBCISlot *slot, const unsigned char *resourc
// session=new eDVBCIAuthSession;
eDebug("[CI SESS] AuthSession");
// break;
case 0x00240041:
if (!eDVBCIInterfaces::getInstance()->isClientConnected())
{
session=new eDVBCIDateTimeSession;
eDebug("[CI SESS] DATE-TIME");
break;
}
case 0x008C1001:
case 0x008D1001:
case 0x008E1001:
case 0x00200041:
if (eDVBCIInterfaces::getInstance()->isClientConnected())
{
session = new eDVBCIPlusHelper(slot, tag, session_nb);
}
break;
default:
eDebug("[CI SESS] unknown resource type %02x %02x %02x %02x", resource_identifier[0], resource_identifier[1], resource_identifier[2],resource_identifier[3]);
session=0;
Expand Down Expand Up @@ -363,14 +324,3 @@ eDVBCISession::~eDVBCISession()
// eDebug("[CI SESS] destroy %p", this);
}

void eDVBCISession::setAction(unsigned int session, int val)
{
if (val)
{
if (sessions[session - 1])
{
sessions[session - 1]->action = val;
sessions[session - 1]->poll();
}
}
}
14 changes: 0 additions & 14 deletions lib/dvb_ci/dvbci_session.h
Expand Up @@ -45,20 +45,6 @@ class eDVBCISession

static int pollAll();

static void setAction(unsigned int session, int val);
};

class eDVBCIPlusHelper: public eDVBCISession
{
eDVBCISlot *m_tslot;
unsigned long m_tag;
int m_session;

int receivedAPDU(const unsigned char *tag, const void *data, int len);
int doAction();
public:
eDVBCIPlusHelper(eDVBCISlot *tslot, unsigned long tag, int session);
~eDVBCIPlusHelper();
};

#endif

0 comments on commit 1cee086

Please sign in to comment.