X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/5c66de23e71d94ddba590c67e4751e046a095e68..4f46a90d789f28eb0ca156caeb2bb55136d8ac85:/lib/dvb_ci/dvbci_session.cpp diff --git a/lib/dvb_ci/dvbci_session.cpp b/lib/dvb_ci/dvbci_session.cpp index a9c26d16..9b5cd875 100644 --- a/lib/dvb_ci/dvbci_session.cpp +++ b/lib/dvb_ci/dvbci_session.cpp @@ -5,6 +5,9 @@ #include #include #include +#include + +eDVBCISession *eDVBCISession::sessions[SLMS]; int eDVBCISession::buildLengthField(unsigned char *pkt, int len) { @@ -78,7 +81,7 @@ void eDVBCISession::sendSPDU(eDVBCISlot *slot, unsigned char tag, const void *da memcpy(ptr, apdu, alen); ptr+=alen; - slot->write(pkt, ptr - pkt); + slot->send(pkt, ptr - pkt); } void eDVBCISession::sendOpenSessionResponse(eDVBCISlot *slot, unsigned char session_status, const unsigned char *resource_identifier, unsigned short session_nb) @@ -110,6 +113,7 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha eDVBCISession *session; unsigned long tag; unsigned short session_nb; + for (session_nb=1; session_nb < SLMS; ++session_nb) if (!sessions[session_nb-1]) break; @@ -129,13 +133,14 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha case 0x00010041: session=new eDVBCIResourceManagerSession; printf("RESOURCE MANAGER\n"); + printf("session: %p\n",session); break; case 0x00020041: - session=slot->application_manager = new eDVBCIApplicationManagerSession; + session=new eDVBCIApplicationManagerSession(slot); printf("APPLICATION MANAGER\n"); break; case 0x00030041: - session=slot->ca_manager=new eDVBCICAManagerSession; + session = new eDVBCICAManagerSession(slot); printf("CA MANAGER\n"); break; case 0x00240041: @@ -143,13 +148,13 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha printf("DATE-TIME\n"); break; case 0x00400041: -// session=new eDVBCIMMISession; - printf("MMI\n"); + session = new eDVBCIMMISession(slot); + printf("MMI - create session\n"); break; case 0x00100041: // session=new eDVBCIAuthSession; printf("AuthSession\n"); - break; +// break; case 0x00200041: default: printf("unknown resource type %02x %02x %02x %02x\n", resource_identifier[0], resource_identifier[1], resource_identifier[2],resource_identifier[3]); @@ -164,27 +169,59 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha } printf("new session_nb: %d\n", session_nb); session->session_nb = session_nb; + if (session) { - printf("session ok, status %02x\n", session->status); - status = session->getStatus(); - if (status) - { - delete session; - session = 0; - } sessions[session_nb - 1] = session; session->slot = slot; + status = 0; } session->state = stateInCreation; + return session; } +void eDVBCISession::handleClose() +{ + unsigned char data[1]={0x00}; + sendSPDU(0x96, data, 1, 0, 0); +} + +int eDVBCISession::pollAll() +{ + for (int session_nb=1; session_nb < SLMS; ++session_nb) + if (sessions[session_nb-1]) + { + int r; + + if (sessions[session_nb-1]->state == stateInDeletion) + { + sessions[session_nb-1]->handleClose(); + delete sessions[session_nb-1]; + sessions[session_nb-1]=0; + r=1; + } else + r=sessions[session_nb-1]->poll(); + + if (r) + return 1; + } + return 0; +} + void eDVBCISession::receiveData(eDVBCISlot *slot, const unsigned char *ptr, size_t len) { const unsigned char *pkt = (const unsigned char*)ptr; unsigned char tag = *pkt++; int llen, hlen; + + printf("slot: %p\n",slot); + + int i; + + for(i=0;isession_nb:0); - + if (session) { session->state=stateStarted; @@ -256,13 +293,13 @@ void eDVBCISession::receiveData(eDVBCISlot *slot, const unsigned char *ptr, size len-=hlen; //if (eDVBCIModule::getInstance()->workarounds_active & eDVBCIModule::workaroundMagicAPDULength) - //{ - // if (((len-alen) > 0) && ((len - alen) < 3)) - // { - // printf("WORKAROUND: applying work around MagicAPDULength\n"); - // alen=len; - // } - //} + { + if (((len-alen) > 0) && ((len - alen) < 3)) + { + printf("WORKAROUND: applying work around MagicAPDULength\n"); + alen=len; + } + } if (session->receivedAPDU(tag, pkt, alen)) session->action = 1; pkt+=alen; @@ -272,3 +309,8 @@ void eDVBCISession::receiveData(eDVBCISlot *slot, const unsigned char *ptr, size if (len) printf("PROTOCOL: warning, TL-Data has invalid length\n"); } + +eDVBCISession::~eDVBCISession() +{ +} +