add the missing ca-mgr code ;)
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 12 Aug 2005 20:10:16 +0000 (20:10 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Fri, 12 Aug 2005 20:10:16 +0000 (20:10 +0000)
lib/dvb_ci/dvbci.h
lib/dvb_ci/dvbci_camgr.cpp
lib/dvb_ci/dvbci_session.cpp
lib/dvb_ci/dvbci_session.h

index 78c1cc8e273177433042293e36194db8ae745289..b72b21b1ef82bdc36e6fb72b87496a9807da84e1 100644 (file)
@@ -4,6 +4,8 @@
 #include <lib/base/ebase.h>
 
 class eDVBCISession;
+class eDVBCIApplicationManagerSession;
+class eDVBCICAManagerSession;
 
 class eDVBCISlot: public iObject, public Object
 {
@@ -22,6 +24,9 @@ public:
        virtual ~eDVBCISlot();
        
        int eDVBCISlot::write(const unsigned char *data, size_t len);
+       
+       eDVBCIApplicationManagerSession *application_manager;
+       eDVBCICAManagerSession *ca_manager;
 };
 
 class eDVBCIInterfaces
index eb30c4102be77b98aa4484511b5132049cb5d32f..2ad1f1e363bb36c06a31ccd214138e78ae24477c 100644 (file)
@@ -2,3 +2,48 @@
 
 #include <lib/dvb_ci/dvbci_camgr.h>
 
+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]);
+       for (int i=0; i<len; i++)
+               printf("%02x ", ((const unsigned char*)data)[i]);
+       printf("\n");
+
+       if ((tag[0]==0x9f) && (tag[1]==0x80))
+       {
+               switch (tag[2])
+               {
+               case 0x31:
+                       printf("ca info:\n");
+                       for (int i=0; i<len; i+=2)
+                       {
+                               printf("%04x ", (((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
+                               caids.insert((((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
+                       }
+                       printf("\n");
+                       break;
+               default:
+                       printf("unknown APDU tag 9F 80 %02x\n", tag[2]);
+                       break;
+               }
+       }
+       return 0;
+}
+
+int eDVBCICAManagerSession::doAction()
+{
+       switch (state)
+       {
+       case stateStarted:
+       {
+               const unsigned char tag[3]={0x9F, 0x80, 0x30}; // ca info enq
+               sendAPDU(tag);
+               state=stateFinal;
+               return 0;
+       }
+       case stateFinal:
+               printf("stateFinal und action! kann doch garnicht sein ;)\n");
+       default:
+               return 0;
+       }
+}
index b0bef25ccda570d74bd71cb898fa64a184b295d0..ab997e5d827a857580e098e3e15f869b837ac24f 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <lib/dvb_ci/dvbci_session.h>
 #include <lib/dvb_ci/dvbci_resmgr.h>
+#include <lib/dvb_ci/dvbci_appmgr.h>
+#include <lib/dvb_ci/dvbci_camgr.h>
 
 int eDVBCISession::buildLengthField(unsigned char *pkt, int len)
 {
@@ -54,6 +56,11 @@ void eDVBCISession::sendAPDU(const unsigned char *tag, const void *data, int len
        sendSPDU(0x90, 0, 0, pkt, len+3+l);
 }
 
+void eDVBCISession::sendSPDU(unsigned char tag, const void *data, int len, const void *apdu, int alen)
+{
+       sendSPDU(slot, tag, data, len, session_nb, apdu, alen);
+}
+
 void eDVBCISession::sendSPDU(eDVBCISlot *slot, unsigned char tag, const void *data, int len, unsigned short session_nb, const void *apdu,int alen)
 {
        unsigned char pkt[4096];
@@ -123,11 +130,11 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha
                printf("RESOURCE MANAGER\n");
                break;
        case 0x00020041:
-//             session=eDVBCIModule::getInstance()->application_manager = new eDVBCIApplicationManagerSession;
+               session=slot->application_manager = new eDVBCIApplicationManagerSession;
                printf("APPLICATION MANAGER\n");
                break;
        case 0x00030041:
-//             session=eDVBCIModule::getInstance()->ca_manager=new eDVBCICAManagerSession;
+               session=slot->ca_manager=new eDVBCICAManagerSession;
                printf("CA MANAGER\n");
                break;
        case 0x00240041:
index 5f95ee82d7c070dbc94da279acd5b110fcbbe45b..dd123eee601bc1f3595aefaa801c70b2db0c6f12 100644 (file)
@@ -22,6 +22,7 @@ protected:
        unsigned short session_nb;
        virtual int receivedAPDU(const unsigned char *tag, const void *data, int len) = 0;
        void eDVBCISession::sendAPDU(const unsigned char *tag, const void *data=0,int len=0);
+       void eDVBCISession::sendSPDU(unsigned char tag, const void *data, int len,const void *apdu=0, int alen=0);
 public:
        enum { stateInCreation, stateBusy, stateInDeletion, stateStarted, statePrivate};